diff options
| author | 2014-09-07 11:50:43 -0700 | |
|---|---|---|
| committer | 2014-09-08 15:43:22 -0700 | |
| commit | 5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f (patch) | |
| tree | b55a6013b561cbb1986a04f2154fe18c0774e891 /src/common/file_util.cpp | |
| parent | loader.cpp: improved file extension checking, made Upper/LowerStr useful (diff) | |
| download | yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar.gz yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar.xz yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.zip | |
Added string_util to common, small changes in loader.cpp
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 b6ff2e40b..2fdc7ec01 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -71,7 +71,7 @@ bool Exists(const std::string &filename) | |||
| 71 | StripTailDirSlashes(copy); | 71 | StripTailDirSlashes(copy); |
| 72 | 72 | ||
| 73 | #ifdef _WIN32 | 73 | #ifdef _WIN32 |
| 74 | int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); | 74 | int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); |
| 75 | #else | 75 | #else |
| 76 | int result = stat64(copy.c_str(), &file_info); | 76 | int result = stat64(copy.c_str(), &file_info); |
| 77 | #endif | 77 | #endif |
| @@ -88,7 +88,7 @@ bool IsDirectory(const std::string &filename) | |||
| 88 | StripTailDirSlashes(copy); | 88 | StripTailDirSlashes(copy); |
| 89 | 89 | ||
| 90 | #ifdef _WIN32 | 90 | #ifdef _WIN32 |
| 91 | int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); | 91 | int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); |
| 92 | #else | 92 | #else |
| 93 | int result = stat64(copy.c_str(), &file_info); | 93 | int result = stat64(copy.c_str(), &file_info); |
| 94 | #endif | 94 | #endif |
| @@ -124,7 +124,7 @@ bool Delete(const std::string &filename) | |||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | #ifdef _WIN32 | 126 | #ifdef _WIN32 |
| 127 | if (!DeleteFile(UTF8ToTStr(filename).c_str())) | 127 | if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) |
| 128 | { | 128 | { |
| 129 | WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", | 129 | WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", |
| 130 | filename.c_str(), GetLastErrorMsg()); | 130 | filename.c_str(), GetLastErrorMsg()); |
| @@ -146,7 +146,7 @@ bool CreateDir(const std::string &path) | |||
| 146 | { | 146 | { |
| 147 | INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); | 147 | INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); |
| 148 | #ifdef _WIN32 | 148 | #ifdef _WIN32 |
| 149 | if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL)) | 149 | if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), NULL)) |
| 150 | return true; | 150 | return true; |
| 151 | DWORD error = GetLastError(); | 151 | DWORD error = GetLastError(); |
| 152 | if (error == ERROR_ALREADY_EXISTS) | 152 | if (error == ERROR_ALREADY_EXISTS) |
| @@ -225,7 +225,7 @@ bool DeleteDir(const std::string &filename) | |||
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | #ifdef _WIN32 | 227 | #ifdef _WIN32 |
| 228 | if (::RemoveDirectory(UTF8ToTStr(filename).c_str())) | 228 | if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str())) |
| 229 | return true; | 229 | return true; |
| 230 | #else | 230 | #else |
| 231 | if (rmdir(filename.c_str()) == 0) | 231 | if (rmdir(filename.c_str()) == 0) |
| @@ -254,7 +254,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) | |||
| 254 | INFO_LOG(COMMON, "Copy: %s --> %s", | 254 | INFO_LOG(COMMON, "Copy: %s --> %s", |
| 255 | srcFilename.c_str(), destFilename.c_str()); | 255 | srcFilename.c_str(), destFilename.c_str()); |
| 256 | #ifdef _WIN32 | 256 | #ifdef _WIN32 |
| 257 | if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE)) | 257 | if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) |
| 258 | return true; | 258 | return true; |
| 259 | 259 | ||
| 260 | ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", | 260 | ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", |
| @@ -342,7 +342,7 @@ u64 GetSize(const std::string &filename) | |||
| 342 | 342 | ||
| 343 | struct stat64 buf; | 343 | struct stat64 buf; |
| 344 | #ifdef _WIN32 | 344 | #ifdef _WIN32 |
| 345 | if (_tstat64(UTF8ToTStr(filename).c_str(), &buf) == 0) | 345 | if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) |
| 346 | #else | 346 | #else |
| 347 | if (stat64(filename.c_str(), &buf) == 0) | 347 | if (stat64(filename.c_str(), &buf) == 0) |
| 348 | #endif | 348 | #endif |
| @@ -415,7 +415,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) | |||
| 415 | // Find the first file in the directory. | 415 | // Find the first file in the directory. |
| 416 | WIN32_FIND_DATA ffd; | 416 | WIN32_FIND_DATA ffd; |
| 417 | 417 | ||
| 418 | HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); | 418 | HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); |
| 419 | if (hFind == INVALID_HANDLE_VALUE) | 419 | if (hFind == INVALID_HANDLE_VALUE) |
| 420 | { | 420 | { |
| 421 | FindClose(hFind); | 421 | FindClose(hFind); |
| @@ -425,7 +425,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) | |||
| 425 | do | 425 | do |
| 426 | { | 426 | { |
| 427 | FSTEntry entry; | 427 | FSTEntry entry; |
| 428 | const std::string virtualName(TStrToUTF8(ffd.cFileName)); | 428 | const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); |
| 429 | #else | 429 | #else |
| 430 | struct dirent dirent, *result = NULL; | 430 | struct dirent dirent, *result = NULL; |
| 431 | 431 | ||
| @@ -482,7 +482,7 @@ bool DeleteDirRecursively(const std::string &directory) | |||
| 482 | #ifdef _WIN32 | 482 | #ifdef _WIN32 |
| 483 | // Find the first file in the directory. | 483 | // Find the first file in the directory. |
| 484 | WIN32_FIND_DATA ffd; | 484 | WIN32_FIND_DATA ffd; |
| 485 | HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); | 485 | HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); |
| 486 | 486 | ||
| 487 | if (hFind == INVALID_HANDLE_VALUE) | 487 | if (hFind == INVALID_HANDLE_VALUE) |
| 488 | { | 488 | { |
| @@ -493,7 +493,7 @@ bool DeleteDirRecursively(const std::string &directory) | |||
| 493 | // windows loop | 493 | // windows loop |
| 494 | do | 494 | do |
| 495 | { | 495 | { |
| 496 | const std::string virtualName(TStrToUTF8(ffd.cFileName)); | 496 | const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); |
| 497 | #else | 497 | #else |
| 498 | struct dirent dirent, *result = NULL; | 498 | struct dirent dirent, *result = NULL; |
| 499 | DIR *dirp = opendir(directory.c_str()); | 499 | DIR *dirp = opendir(directory.c_str()); |
| @@ -631,7 +631,7 @@ std::string& GetExeDirectory() | |||
| 631 | { | 631 | { |
| 632 | TCHAR Dolphin_exe_Path[2048]; | 632 | TCHAR Dolphin_exe_Path[2048]; |
| 633 | GetModuleFileName(NULL, Dolphin_exe_Path, 2048); | 633 | GetModuleFileName(NULL, Dolphin_exe_Path, 2048); |
| 634 | DolphinPath = TStrToUTF8(Dolphin_exe_Path); | 634 | DolphinPath = Common::TStrToUTF8(Dolphin_exe_Path); |
| 635 | DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); | 635 | DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); |
| 636 | } | 636 | } |
| 637 | return DolphinPath; | 637 | return DolphinPath; |
| @@ -826,7 +826,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[]) | |||
| 826 | { | 826 | { |
| 827 | Close(); | 827 | Close(); |
| 828 | #ifdef _WIN32 | 828 | #ifdef _WIN32 |
| 829 | _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); | 829 | _tfopen_s(&m_file, Common::UTF8ToTStr(filename).c_str(), Common::UTF8ToTStr(openmode).c_str()); |
| 830 | #else | 830 | #else |
| 831 | m_file = fopen(filename.c_str(), openmode); | 831 | m_file = fopen(filename.c_str(), openmode); |
| 832 | #endif | 832 | #endif |