diff options
| author | 2014-09-11 00:04:36 -0400 | |
|---|---|---|
| committer | 2014-09-11 00:04:36 -0400 | |
| commit | 532a9e80a0bd242d2937335063b719130405d6bc (patch) | |
| tree | 84fe1f054b62edc488a7a9e80eb8f79b2dd05cd0 /src/common/file_util.cpp | |
| parent | Merge pull request #103 from archshift/prune (diff) | |
| parent | Moved common_types::Rect from common to Common namespace (diff) | |
| download | yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.gz yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.xz yuzu-532a9e80a0bd242d2937335063b719130405d6bc.zip | |
Merge pull request #99 from archshift/ext-check
loader.cpp: improved file extension checking, made Upper/LowerStr useful, moved string_util into Common namespace
Diffstat (limited to 'src/common/file_util.cpp')
| -rw-r--r-- | src/common/file_util.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 04d222ca1..970041007 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -64,7 +64,7 @@ bool Exists(const std::string &filename) | |||
| 64 | StripTailDirSlashes(copy); | 64 | StripTailDirSlashes(copy); |
| 65 | 65 | ||
| 66 | #ifdef _WIN32 | 66 | #ifdef _WIN32 |
| 67 | int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); | 67 | int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); |
| 68 | #else | 68 | #else |
| 69 | int result = stat64(copy.c_str(), &file_info); | 69 | int result = stat64(copy.c_str(), &file_info); |
| 70 | #endif | 70 | #endif |
| @@ -81,7 +81,7 @@ bool IsDirectory(const std::string &filename) | |||
| 81 | StripTailDirSlashes(copy); | 81 | StripTailDirSlashes(copy); |
| 82 | 82 | ||
| 83 | #ifdef _WIN32 | 83 | #ifdef _WIN32 |
| 84 | int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); | 84 | int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); |
| 85 | #else | 85 | #else |
| 86 | int result = stat64(copy.c_str(), &file_info); | 86 | int result = stat64(copy.c_str(), &file_info); |
| 87 | #endif | 87 | #endif |
| @@ -117,7 +117,7 @@ bool Delete(const std::string &filename) | |||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #ifdef _WIN32 | 119 | #ifdef _WIN32 |
| 120 | if (!DeleteFile(UTF8ToTStr(filename).c_str())) | 120 | if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) |
| 121 | { | 121 | { |
| 122 | WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", | 122 | WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", |
| 123 | filename.c_str(), GetLastErrorMsg()); | 123 | filename.c_str(), GetLastErrorMsg()); |
| @@ -139,7 +139,7 @@ bool CreateDir(const std::string &path) | |||
| 139 | { | 139 | { |
| 140 | INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); | 140 | INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); |
| 141 | #ifdef _WIN32 | 141 | #ifdef _WIN32 |
| 142 | if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL)) | 142 | if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), NULL)) |
| 143 | return true; | 143 | return true; |
| 144 | DWORD error = GetLastError(); | 144 | DWORD error = GetLastError(); |
| 145 | if (error == ERROR_ALREADY_EXISTS) | 145 | if (error == ERROR_ALREADY_EXISTS) |
| @@ -218,7 +218,7 @@ bool DeleteDir(const std::string &filename) | |||
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | #ifdef _WIN32 | 220 | #ifdef _WIN32 |
| 221 | if (::RemoveDirectory(UTF8ToTStr(filename).c_str())) | 221 | if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str())) |
| 222 | return true; | 222 | return true; |
| 223 | #else | 223 | #else |
| 224 | if (rmdir(filename.c_str()) == 0) | 224 | if (rmdir(filename.c_str()) == 0) |
| @@ -247,7 +247,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) | |||
| 247 | INFO_LOG(COMMON, "Copy: %s --> %s", | 247 | INFO_LOG(COMMON, "Copy: %s --> %s", |
| 248 | srcFilename.c_str(), destFilename.c_str()); | 248 | srcFilename.c_str(), destFilename.c_str()); |
| 249 | #ifdef _WIN32 | 249 | #ifdef _WIN32 |
| 250 | if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE)) | 250 | if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) |
| 251 | return true; | 251 | return true; |
| 252 | 252 | ||
| 253 | ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", | 253 | ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", |
| @@ -335,7 +335,7 @@ u64 GetSize(const std::string &filename) | |||
| 335 | 335 | ||
| 336 | struct stat64 buf; | 336 | struct stat64 buf; |
| 337 | #ifdef _WIN32 | 337 | #ifdef _WIN32 |
| 338 | if (_tstat64(UTF8ToTStr(filename).c_str(), &buf) == 0) | 338 | if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) |
| 339 | #else | 339 | #else |
| 340 | if (stat64(filename.c_str(), &buf) == 0) | 340 | if (stat64(filename.c_str(), &buf) == 0) |
| 341 | #endif | 341 | #endif |
| @@ -408,7 +408,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) | |||
| 408 | // Find the first file in the directory. | 408 | // Find the first file in the directory. |
| 409 | WIN32_FIND_DATA ffd; | 409 | WIN32_FIND_DATA ffd; |
| 410 | 410 | ||
| 411 | HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); | 411 | HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); |
| 412 | if (hFind == INVALID_HANDLE_VALUE) | 412 | if (hFind == INVALID_HANDLE_VALUE) |
| 413 | { | 413 | { |
| 414 | FindClose(hFind); | 414 | FindClose(hFind); |
| @@ -418,7 +418,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) | |||
| 418 | do | 418 | do |
| 419 | { | 419 | { |
| 420 | FSTEntry entry; | 420 | FSTEntry entry; |
| 421 | const std::string virtualName(TStrToUTF8(ffd.cFileName)); | 421 | const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); |
| 422 | #else | 422 | #else |
| 423 | struct dirent dirent, *result = NULL; | 423 | struct dirent dirent, *result = NULL; |
| 424 | 424 | ||
| @@ -475,7 +475,7 @@ bool DeleteDirRecursively(const std::string &directory) | |||
| 475 | #ifdef _WIN32 | 475 | #ifdef _WIN32 |
| 476 | // Find the first file in the directory. | 476 | // Find the first file in the directory. |
| 477 | WIN32_FIND_DATA ffd; | 477 | WIN32_FIND_DATA ffd; |
| 478 | HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); | 478 | HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); |
| 479 | 479 | ||
| 480 | if (hFind == INVALID_HANDLE_VALUE) | 480 | if (hFind == INVALID_HANDLE_VALUE) |
| 481 | { | 481 | { |
| @@ -486,7 +486,7 @@ bool DeleteDirRecursively(const std::string &directory) | |||
| 486 | // windows loop | 486 | // windows loop |
| 487 | do | 487 | do |
| 488 | { | 488 | { |
| 489 | const std::string virtualName(TStrToUTF8(ffd.cFileName)); | 489 | const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); |
| 490 | #else | 490 | #else |
| 491 | struct dirent dirent, *result = NULL; | 491 | struct dirent dirent, *result = NULL; |
| 492 | DIR *dirp = opendir(directory.c_str()); | 492 | DIR *dirp = opendir(directory.c_str()); |
| @@ -624,7 +624,7 @@ std::string& GetExeDirectory() | |||
| 624 | { | 624 | { |
| 625 | TCHAR Dolphin_exe_Path[2048]; | 625 | TCHAR Dolphin_exe_Path[2048]; |
| 626 | GetModuleFileName(NULL, Dolphin_exe_Path, 2048); | 626 | GetModuleFileName(NULL, Dolphin_exe_Path, 2048); |
| 627 | DolphinPath = TStrToUTF8(Dolphin_exe_Path); | 627 | DolphinPath = Common::TStrToUTF8(Dolphin_exe_Path); |
| 628 | DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); | 628 | DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); |
| 629 | } | 629 | } |
| 630 | return DolphinPath; | 630 | return DolphinPath; |
| @@ -819,7 +819,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[]) | |||
| 819 | { | 819 | { |
| 820 | Close(); | 820 | Close(); |
| 821 | #ifdef _WIN32 | 821 | #ifdef _WIN32 |
| 822 | _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); | 822 | _tfopen_s(&m_file, Common::UTF8ToTStr(filename).c_str(), Common::UTF8ToTStr(openmode).c_str()); |
| 823 | #else | 823 | #else |
| 824 | m_file = fopen(filename.c_str(), openmode); | 824 | m_file = fopen(filename.c_str(), openmode); |
| 825 | #endif | 825 | #endif |