summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
authorfires.gc <fires.gc@gmail.com>2008-11-02 14:43:22 +0000
committerfires.gc <fires.gc@gmail.com>2008-11-02 14:43:22 +0000
commit5ae441d6bc622c59602774e9a9b06a6307d0d5f5 (patch)
tree6512195dde1450daa737ba9939286ba3cc4e43c2 /Source/Core/Common/Src/FileUtil.cpp
parent342c5597190d1276586bd7d03badda783e68e86e (diff)
some more HLE of the IPC
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1049 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index bc141a5517..7660aeb824 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -148,6 +148,21 @@ bool CreateDir(const char *path)
#endif
}
+bool DeleteDir(const char *filename)
+{
+#ifdef _WIN32
+ if (!File::IsDirectory(filename))
+ return false;
+
+ return ::RemoveDirectory (filename) ? true : false;
+#else
+
+ PanicAlert("File::DeleteDir() not implemented");
+ return false;
+
+#endif
+}
+
std::string GetUserDirectory()
{
#ifdef _WIN32
@@ -254,4 +269,61 @@ bool CreateEmptyFile(const char *filename)
return true;
}
+
+bool DeleteDirRecursively(const std::string& _Directory)
+{
+#ifdef _WIN32
+
+ bool Result = false;
+
+ WIN32_FIND_DATA ffd;
+ std::string searchName = _Directory + "\\*";
+ HANDLE hFind = FindFirstFile(searchName.c_str(), &ffd);
+
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ // check for "." and ".."
+ if (((ffd.cFileName[0] == '.') && (ffd.cFileName[1] == 0x00)) ||
+ ((ffd.cFileName[0] == '.') && (ffd.cFileName[1] == '.') && (ffd.cFileName[2] == 0x00)))
+ continue;
+
+ // build path
+ std::string newPath(_Directory);
+ newPath += '\\';
+ newPath += ffd.cFileName;
+
+ if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ if (!File::DeleteDirRecursively(newPath))
+ goto error_jmp;
+ }
+ else
+ {
+ if (!File::Delete(newPath.c_str()))
+ goto error_jmp;
+ }
+
+ } while (FindNextFile(hFind, &ffd) != 0);
+ }
+
+ if (!File::DeleteDir(_Directory.c_str()))
+ goto error_jmp;
+
+ Result = true;
+
+error_jmp:
+
+ FindClose(hFind);
+
+ return Result;
+#else
+
+ PanicAlert("File::DeleteDirRecursively() not implemented");
+ return false;
+
+#endif
+}
+
} // namespace