diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index 7d972bc33..86e406980 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -217,7 +217,7 @@ size_t GetFilesInDir(const char *directory, std::vector * files, const return foundEntries; } -int64_t getDirectoryRecursiveSize(const std::string & path, const char *filter, int flags) { +int64_t GetDirectoryRecursiveSize(const std::string & path, const char *filter, int flags) { std::vector fileInfo; GetFilesInDir(path.c_str(), &fileInfo, filter, flags); int64_t sizeSum = 0; @@ -228,14 +228,14 @@ int64_t getDirectoryRecursiveSize(const std::string & path, const char *filter, if (!finfo.isDirectory) sizeSum += finfo.size; else - sizeSum += getDirectoryRecursiveSize(finfo.fullName, filter, flags); + sizeSum += GetDirectoryRecursiveSize(finfo.fullName, filter, flags); } return sizeSum; } #ifdef _WIN32 // Returns a vector with the device names -std::vector getWindowsDrives() +std::vector GetWindowsDrives() { #if PPSSPP_PLATFORM(UWP) return std::vector(); // TODO UWP http://stackoverflow.com/questions/37404405/how-to-get-logical-drives-names-in-windows-10 diff --git a/Common/File/DirListing.h b/Common/File/DirListing.h index b039e3744..dea4f1b66 100644 --- a/Common/File/DirListing.h +++ b/Common/File/DirListing.h @@ -33,10 +33,10 @@ enum { GETFILES_GETHIDDEN = 1 }; size_t GetFilesInDir(const char *directory, std::vector *files, const char *filter = nullptr, int flags = 0); -int64_t getDirectoryRecursiveSize(const std::string &path, const char *filter = nullptr, int flags = 0); +int64_t GetDirectoryRecursiveSize(const std::string &path, const char *filter = nullptr, int flags = 0); #ifdef _WIN32 -std::vector getWindowsDrives(); +std::vector GetWindowsDrives(); #endif } diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index c0ecca6a1..c289722d3 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -377,7 +377,6 @@ bool CreateFullPath(const std::string &path) } } - // Deletes a directory filename, returns true on success bool DeleteDir(const std::string &filename) { @@ -696,48 +695,6 @@ bool DeleteDirRecursively(const std::string &directory) return File::DeleteDir(directory); } - -// Create directory and copy contents (does not overwrite existing files) -void CopyDir(const std::string &source_path, const std::string &dest_path) -{ -#ifndef _WIN32 - if (source_path == dest_path) return; - if (!File::Exists(source_path)) return; - if (!File::Exists(dest_path)) File::CreateFullPath(dest_path); - - struct dirent *result = NULL; - DIR *dirp = opendir(source_path.c_str()); - if (!dirp) return; - - while ((result = readdir(dirp))) { - const std::string virtualName(result->d_name); - // check for "." and ".." - if (((virtualName[0] == '.') && (virtualName[1] == '\0')) || - ((virtualName[0] == '.') && (virtualName[1] == '.') && - (virtualName[2] == '\0'))) { - continue; - } - - std::string source, dest; - source = source_path + virtualName; - dest = dest_path + virtualName; - if (IsDirectory(source)) { - source += '/'; - dest += '/'; - if (!File::Exists(dest)) { - File::CreateFullPath(dest); - } - CopyDir(source, dest); - } else if (!File::Exists(dest)) { - File::Copy(source, dest); - } - } - closedir(dirp); -#else - ERROR_LOG(COMMON, "CopyDir not supported on this platform"); -#endif -} - void OpenFileInEditor(const std::string& fileName) { #if defined(_WIN32) #if PPSSPP_PLATFORM(UWP) diff --git a/Common/File/FileUtil.h b/Common/File/FileUtil.h index 5abf9970e..1c11fcd94 100644 --- a/Common/File/FileUtil.h +++ b/Common/File/FileUtil.h @@ -36,7 +36,7 @@ inline struct tm* localtime_r(const time_t *clock, struct tm *result) { namespace File { -// Mostly to handle utf-8 filenames better on Windows. +// Mostly to handle UTF-8 filenames better on Windows. FILE *OpenCFile(const std::string &filename, const char *mode); bool OpenCPPFile(std::fstream & stream, const std::string &filename, std::ios::openmode mode); @@ -78,6 +78,7 @@ bool CreateFullPath(const std::string &fullPath); bool Delete(const std::string &filename); // Deletes a directory filename, returns true on success +// Directory must be empty. bool DeleteDir(const std::string &filename); // renames file srcFilename to destFilename, returns true on success @@ -92,9 +93,6 @@ bool CreateEmptyFile(const std::string &filename); // deletes the given directory and anything under it. Returns true on success. bool DeleteDirRecursively(const std::string &directory); -// Create directory and copy contents (does not overwrite existing files) -void CopyDir(const std::string &source_path, const std::string &dest_path); - // Opens ini file (cheats, texture replacements etc.) // TODO: Belongs in System or something. void OpenFileInEditor(const std::string& fileName); diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 9d8f29f35..052446af0 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -246,7 +246,7 @@ bool PathBrowser::GetListing(std::vector &fileInfo, const char * #ifdef _WIN32 if (path_ == "/") { // Special path that means root of file system. - std::vector drives = File::getWindowsDrives(); + std::vector drives = File::GetWindowsDrives(); for (auto drive = drives.begin(); drive != drives.end(); ++drive) { if (*drive == "A:/" || *drive == "B:/") continue; diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 1fdaad31c..0274c03ba 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -113,7 +113,7 @@ u64 GameInfo::GetGameSizeInBytes() { switch (fileType) { case IdentifiedFileType::PSP_PBP_DIRECTORY: case IdentifiedFileType::PSP_SAVEDATA_DIRECTORY: - return File::getDirectoryRecursiveSize(ResolvePBPDirectory(filePath_), nullptr, File::GETFILES_GETHIDDEN); + return File::GetDirectoryRecursiveSize(ResolvePBPDirectory(filePath_), nullptr, File::GETFILES_GETHIDDEN); default: return GetFileLoader()->FileSize(); diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 6d3e629a9..54c1618af 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -430,7 +430,7 @@ static time_t GetTotalSize(const SavedataButton *b) { switch (Identify_File(fileLoader.get())) { case IdentifiedFileType::PSP_PBP_DIRECTORY: case IdentifiedFileType::PSP_SAVEDATA_DIRECTORY: - return File::getDirectoryRecursiveSize(ResolvePBPDirectory(b->GamePath()), nullptr, File::GETFILES_GETHIDDEN); + return File::GetDirectoryRecursiveSize(ResolvePBPDirectory(b->GamePath()), nullptr, File::GETFILES_GETHIDDEN); default: return fileLoader->FileSize();