diff options
author | archshift <admin@archshift.com> | 2014-09-07 20:50:43 +0200 |
---|---|---|
committer | archshift <admin@archshift.com> | 2014-09-09 00:43:22 +0200 |
commit | 5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f (patch) | |
tree | b55a6013b561cbb1986a04f2154fe18c0774e891 /src/common | |
parent | loader.cpp: improved file extension checking, made Upper/LowerStr useful (diff) | |
download | yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar.gz yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar.bz2 yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar.lz yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar.xz yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.tar.zst yuzu-5472fd4d9b19011a36604a9c7f9c66f3ebe84e3f.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/console_listener.cpp | 10 | ||||
-rw-r--r-- | src/common/extended_trace.cpp | 2 | ||||
-rw-r--r-- | src/common/file_search.cpp | 6 | ||||
-rw-r--r-- | src/common/file_util.cpp | 26 | ||||
-rw-r--r-- | src/common/file_util.h | 2 | ||||
-rw-r--r-- | src/common/log_manager.cpp | 2 | ||||
-rw-r--r-- | src/common/mem_arena.cpp | 2 | ||||
-rw-r--r-- | src/common/memory_util.cpp | 2 | ||||
-rw-r--r-- | src/common/msg_handler.cpp | 2 | ||||
-rw-r--r-- | src/common/string_util.cpp | 8 | ||||
-rw-r--r-- | src/common/string_util.h | 9 |
11 files changed, 39 insertions, 32 deletions
diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp index 27697ef1f..96970ab17 100644 --- a/src/common/console_listener.cpp +++ b/src/common/console_listener.cpp @@ -47,7 +47,7 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title // Save the window handle that AllocConsole() created hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Set the console window title - SetConsoleTitle(UTF8ToTStr(Title).c_str()); + SetConsoleTitle(Common::UTF8ToTStr(Title).c_str()); // Set letter space LetterSpace(80, 4000); //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); @@ -193,11 +193,11 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool { Str.resize(Str.size() + 1); if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead)) - SLog += StringFromFormat("WriteConsoleOutputCharacter error"); + SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); Attr.resize(Attr.size() + 1); if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead)) - SLog += StringFromFormat("WriteConsoleOutputAttribute error"); + SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); // Break on error if (cAttrRead == 0) break; @@ -223,9 +223,9 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool for (size_t i = 0; i < Attr.size(); i++) { if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten)) - SLog += StringFromFormat("WriteConsoleOutputCharacter error"); + SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten)) - SLog += StringFromFormat("WriteConsoleOutputAttribute error"); + SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); BytesWritten += cAttrWritten; coordScreen = GetCoordinates(BytesWritten, LBufWidth); diff --git a/src/common/extended_trace.cpp b/src/common/extended_trace.cpp index 66dae4935..9cd0398ed 100644 --- a/src/common/extended_trace.cpp +++ b/src/common/extended_trace.cpp @@ -278,7 +278,7 @@ void PrintFunctionAndSourceInfo(FILE* file, const STACKFRAME& callstack) GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo); GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo); - etfprint(file, " " + TStrToUTF8(srcInfo) + " : " + TStrToUTF8(symInfo) + "\n"); + etfprint(file, " " + Common::TStrToUTF8(srcInfo) + " : " + Common::TStrToUTF8(symInfo) + "\n"); } void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file ) diff --git a/src/common/file_search.cpp b/src/common/file_search.cpp index a9d19477d..a80a98820 100644 --- a/src/common/file_search.cpp +++ b/src/common/file_search.cpp @@ -35,10 +35,10 @@ CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, cons void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath) { std::string GCMSearchPath; - BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); + Common::BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); #ifdef _WIN32 WIN32_FIND_DATA findData; - HANDLE FindFirst = FindFirstFile(UTF8ToTStr(GCMSearchPath).c_str(), &findData); + HANDLE FindFirst = FindFirstFile(Common::UTF8ToTStr(GCMSearchPath).c_str(), &findData); if (FindFirst != INVALID_HANDLE_VALUE) { @@ -49,7 +49,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& if (findData.cFileName[0] != '.') { std::string strFilename; - BuildCompleteFilename(strFilename, _strPath, TStrToUTF8(findData.cFileName)); + Common::BuildCompleteFilename(strFilename, _strPath, Common::TStrToUTF8(findData.cFileName)); m_FileNames.push_back(strFilename); } 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) StripTailDirSlashes(copy); #ifdef _WIN32 - int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); + int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); #else int result = stat64(copy.c_str(), &file_info); #endif @@ -88,7 +88,7 @@ bool IsDirectory(const std::string &filename) StripTailDirSlashes(copy); #ifdef _WIN32 - int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); + int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); #else int result = stat64(copy.c_str(), &file_info); #endif @@ -124,7 +124,7 @@ bool Delete(const std::string &filename) } #ifdef _WIN32 - if (!DeleteFile(UTF8ToTStr(filename).c_str())) + if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) { WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg()); @@ -146,7 +146,7 @@ bool CreateDir(const std::string &path) { INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); #ifdef _WIN32 - if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL)) + if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), NULL)) return true; DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) @@ -225,7 +225,7 @@ bool DeleteDir(const std::string &filename) } #ifdef _WIN32 - if (::RemoveDirectory(UTF8ToTStr(filename).c_str())) + if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str())) return true; #else if (rmdir(filename.c_str()) == 0) @@ -254,7 +254,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) INFO_LOG(COMMON, "Copy: %s --> %s", srcFilename.c_str(), destFilename.c_str()); #ifdef _WIN32 - if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE)) + if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) return true; ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", @@ -342,7 +342,7 @@ u64 GetSize(const std::string &filename) struct stat64 buf; #ifdef _WIN32 - if (_tstat64(UTF8ToTStr(filename).c_str(), &buf) == 0) + if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) #else if (stat64(filename.c_str(), &buf) == 0) #endif @@ -415,7 +415,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) // Find the first file in the directory. WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); + HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); @@ -425,7 +425,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) do { FSTEntry entry; - const std::string virtualName(TStrToUTF8(ffd.cFileName)); + const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); #else struct dirent dirent, *result = NULL; @@ -482,7 +482,7 @@ bool DeleteDirRecursively(const std::string &directory) #ifdef _WIN32 // Find the first file in the directory. WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); + HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { @@ -493,7 +493,7 @@ bool DeleteDirRecursively(const std::string &directory) // windows loop do { - const std::string virtualName(TStrToUTF8(ffd.cFileName)); + const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); #else struct dirent dirent, *result = NULL; DIR *dirp = opendir(directory.c_str()); @@ -631,7 +631,7 @@ std::string& GetExeDirectory() { TCHAR Dolphin_exe_Path[2048]; GetModuleFileName(NULL, Dolphin_exe_Path, 2048); - DolphinPath = TStrToUTF8(Dolphin_exe_Path); + DolphinPath = Common::TStrToUTF8(Dolphin_exe_Path); DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); } return DolphinPath; @@ -826,7 +826,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[]) { Close(); #ifdef _WIN32 - _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); + _tfopen_s(&m_file, Common::UTF8ToTStr(filename).c_str(), Common::UTF8ToTStr(openmode).c_str()); #else m_file = fopen(filename.c_str(), openmode); #endif diff --git a/src/common/file_util.h b/src/common/file_util.h index 0871734d4..fdae5c9c8 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -213,7 +213,7 @@ template <typename T> void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) { #ifdef _WIN32 - fstream.open(UTF8ToTStr(filename).c_str(), openmode); + fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode); #else fstream.open(filename.c_str(), openmode); #endif diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index 4e1cb60bd..9fd019fb3 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp @@ -121,7 +121,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) return; - CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); + Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); static const char level_to_char[7] = "ONEWID"; sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp index b76ac92d3..d4dd933bf 100644 --- a/src/common/mem_arena.cpp +++ b/src/common/mem_arena.cpp @@ -143,7 +143,7 @@ void MemArena::GrabLowMemSpace(size_t size) // a bit more. for (int i = 0; i < 10000; i++) { - std::string file_name = StringFromFormat("/citramem.%d", i); + std::string file_name = Common::StringFromFormat("/citramem.%d", i); fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); if (fd != -1) { diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index e01e63175..1496002e9 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -190,7 +190,7 @@ std::string MemUsage() if (NULL == hProcess) return "MemUsage Error"; if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) - Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); + Ret = Common::StringFromFormat("%s K", Common::ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); CloseHandle(hProcess); return Ret; diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp index 3e02ec4d7..b3556aaa8 100644 --- a/src/common/msg_handler.cpp +++ b/src/common/msg_handler.cpp @@ -72,7 +72,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) va_list args; va_start(args, format); - CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); + Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); va_end(args); ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index c489c868b..bd4c33391 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -17,14 +17,16 @@ #include <iconv.h> #endif +namespace Common { + /// Make a string lowercase -std::string LowerStr(std::string str) { +std::string ToLower(std::string str) { std::transform(str.begin(), str.end(), str.begin(), ::tolower); return str; } /// Make a string uppercase -std::string UpperStr(std::string str) { +std::string ToUpper(std::string str) { std::transform(str.begin(), str.end(), str.begin(), ::toupper); return str; } @@ -541,3 +543,5 @@ std::string UTF16ToUTF8(const std::wstring& input) } #endif + +} diff --git a/src/common/string_util.h b/src/common/string_util.h index b1118816e..16ce39bc1 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -12,12 +12,13 @@ #include "common/common.h" -/// Make a string lowercase +namespace Common { -std::string LowerStr(std::string str); +/// Make a string lowercase +std::string ToLower(std::string str); /// Make a string uppercase -std::string UpperStr(std::string str); +std::string ToUpper(std::string str); std::string StringFromFormat(const char* format, ...); // Cheap! @@ -112,3 +113,5 @@ inline std::string UTF8ToTStr(const std::string& str) #endif #endif + +} |