From 5ae441d6bc622c59602774e9a9b06a6307d0d5f5 Mon Sep 17 00:00:00 2001 From: "fires.gc" Date: Sun, 2 Nov 2008 14:43:22 +0000 Subject: some more HLE of the IPC git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1049 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'Source/Core/Common/Src/FileUtil.cpp') 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 -- cgit v1.2.3