summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp43
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)
{