diff options
| author | John Peterson <jpeterson57@gmail.com> | 2008-11-29 09:54:39 +0000 |
|---|---|---|
| committer | John Peterson <jpeterson57@gmail.com> | 2008-11-29 09:54:39 +0000 |
| commit | 852c6aaca179f7498ec6c6f016fd9c4dfccfe3d3 (patch) | |
| tree | 0b1d962540ecbcc650e814cfb8e8c10e778e36f6 /Source/Core/Common/Src/FileUtil.cpp | |
| parent | 409720b91a58d4eff79d959ca00f65ee4ad4246d (diff) | |
Create a dir for setting.txt to
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1328 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
| -rw-r--r-- | Source/Core/Common/Src/FileUtil.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 60bee857e1..68d333eb7a 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -149,6 +149,49 @@ bool CreateDir(const char *path) #endif
}
+// Create several dirs
+bool CreateDirectoryStructure(const std::string& _rFullPath)
+{
+ int PanicCounter = 10;
+
+ size_t Position = 0;
+ while(true)
+ {
+ // find next sub path
+ {
+ size_t nextPosition = _rFullPath.find('/', Position);
+ if (nextPosition == std::string::npos)
+ nextPosition = _rFullPath.find('\\', Position);
+ Position = nextPosition;
+
+ if (Position == std::string::npos)
+ return true;
+
+ Position++;
+ }
+
+ // create next sub path
+ std::string SubPath = _rFullPath.substr(0, Position);
+ if (!SubPath.empty())
+ {
+ if (!File::IsDirectory(SubPath.c_str()))
+ {
+ File::CreateDir(SubPath.c_str());
+ LOG(WII_IPC_FILEIO, " CreateSubDir %s", SubPath.c_str());
+ }
+ }
+
+ // just a safty check...
+ PanicCounter--;
+ if (PanicCounter <= 0)
+ {
+ PanicAlert("CreateDirectoryStruct creates way to much dirs...");
+ return false;
+ }
+ }
+}
+
+
bool DeleteDir(const char *filename)
{
|
