summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/console_listener.cpp10
-rw-r--r--src/common/extended_trace.cpp2
-rw-r--r--src/common/file_search.cpp6
-rw-r--r--src/common/file_util.cpp26
-rw-r--r--src/common/file_util.h2
-rw-r--r--src/common/log_manager.cpp2
-rw-r--r--src/common/mem_arena.cpp2
-rw-r--r--src/common/memory_util.cpp2
-rw-r--r--src/common/msg_handler.cpp2
-rw-r--r--src/common/string_util.cpp8
-rw-r--r--src/common/string_util.h9
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
47 // Save the window handle that AllocConsole() created 47 // Save the window handle that AllocConsole() created
48 hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 48 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
49 // Set the console window title 49 // Set the console window title
50 SetConsoleTitle(UTF8ToTStr(Title).c_str()); 50 SetConsoleTitle(Common::UTF8ToTStr(Title).c_str());
51 // Set letter space 51 // Set letter space
52 LetterSpace(80, 4000); 52 LetterSpace(80, 4000);
53 //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); 53 //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true);
@@ -193,11 +193,11 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
193 { 193 {
194 Str.resize(Str.size() + 1); 194 Str.resize(Str.size() + 1);
195 if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead)) 195 if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead))
196 SLog += StringFromFormat("WriteConsoleOutputCharacter error"); 196 SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error");
197 197
198 Attr.resize(Attr.size() + 1); 198 Attr.resize(Attr.size() + 1);
199 if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead)) 199 if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead))
200 SLog += StringFromFormat("WriteConsoleOutputAttribute error"); 200 SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error");
201 201
202 // Break on error 202 // Break on error
203 if (cAttrRead == 0) break; 203 if (cAttrRead == 0) break;
@@ -223,9 +223,9 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
223 for (size_t i = 0; i < Attr.size(); i++) 223 for (size_t i = 0; i < Attr.size(); i++)
224 { 224 {
225 if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten)) 225 if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten))
226 SLog += StringFromFormat("WriteConsoleOutputCharacter error"); 226 SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error");
227 if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten)) 227 if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten))
228 SLog += StringFromFormat("WriteConsoleOutputAttribute error"); 228 SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error");
229 229
230 BytesWritten += cAttrWritten; 230 BytesWritten += cAttrWritten;
231 coordScreen = GetCoordinates(BytesWritten, LBufWidth); 231 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)
278 278
279 GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo); 279 GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo);
280 GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo); 280 GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo);
281 etfprint(file, " " + TStrToUTF8(srcInfo) + " : " + TStrToUTF8(symInfo) + "\n"); 281 etfprint(file, " " + Common::TStrToUTF8(srcInfo) + " : " + Common::TStrToUTF8(symInfo) + "\n");
282} 282}
283 283
284void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file ) 284void 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
35void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath) 35void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath)
36{ 36{
37 std::string GCMSearchPath; 37 std::string GCMSearchPath;
38 BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); 38 Common::BuildCompleteFilename(GCMSearchPath, _strPath, _searchString);
39#ifdef _WIN32 39#ifdef _WIN32
40 WIN32_FIND_DATA findData; 40 WIN32_FIND_DATA findData;
41 HANDLE FindFirst = FindFirstFile(UTF8ToTStr(GCMSearchPath).c_str(), &findData); 41 HANDLE FindFirst = FindFirstFile(Common::UTF8ToTStr(GCMSearchPath).c_str(), &findData);
42 42
43 if (FindFirst != INVALID_HANDLE_VALUE) 43 if (FindFirst != INVALID_HANDLE_VALUE)
44 { 44 {
@@ -49,7 +49,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
49 if (findData.cFileName[0] != '.') 49 if (findData.cFileName[0] != '.')
50 { 50 {
51 std::string strFilename; 51 std::string strFilename;
52 BuildCompleteFilename(strFilename, _strPath, TStrToUTF8(findData.cFileName)); 52 Common::BuildCompleteFilename(strFilename, _strPath, Common::TStrToUTF8(findData.cFileName));
53 m_FileNames.push_back(strFilename); 53 m_FileNames.push_back(strFilename);
54 } 54 }
55 55
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
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>
213void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) 213void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
214{ 214{
215#ifdef _WIN32 215#ifdef _WIN32
216 fstream.open(UTF8ToTStr(filename).c_str(), openmode); 216 fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode);
217#else 217#else
218 fstream.open(filename.c_str(), openmode); 218 fstream.open(filename.c_str(), openmode);
219#endif 219#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
121 if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) 121 if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
122 return; 122 return;
123 123
124 CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); 124 Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args);
125 125
126 static const char level_to_char[7] = "ONEWID"; 126 static const char level_to_char[7] = "ONEWID";
127 sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, 127 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)
143 // a bit more. 143 // a bit more.
144 for (int i = 0; i < 10000; i++) 144 for (int i = 0; i < 10000; i++)
145 { 145 {
146 std::string file_name = StringFromFormat("/citramem.%d", i); 146 std::string file_name = Common::StringFromFormat("/citramem.%d", i);
147 fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); 147 fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
148 if (fd != -1) 148 if (fd != -1)
149 { 149 {
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()
190 if (NULL == hProcess) return "MemUsage Error"; 190 if (NULL == hProcess) return "MemUsage Error";
191 191
192 if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) 192 if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))
193 Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); 193 Ret = Common::StringFromFormat("%s K", Common::ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str());
194 194
195 CloseHandle(hProcess); 195 CloseHandle(hProcess);
196 return Ret; 196 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, ...)
72 72
73 va_list args; 73 va_list args;
74 va_start(args, format); 74 va_start(args, format);
75 CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); 75 Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args);
76 va_end(args); 76 va_end(args);
77 77
78 ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); 78 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 @@
17 #include <iconv.h> 17 #include <iconv.h>
18#endif 18#endif
19 19
20namespace Common {
21
20/// Make a string lowercase 22/// Make a string lowercase
21std::string LowerStr(std::string str) { 23std::string ToLower(std::string str) {
22 std::transform(str.begin(), str.end(), str.begin(), ::tolower); 24 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
23 return str; 25 return str;
24} 26}
25 27
26/// Make a string uppercase 28/// Make a string uppercase
27std::string UpperStr(std::string str) { 29std::string ToUpper(std::string str) {
28 std::transform(str.begin(), str.end(), str.begin(), ::toupper); 30 std::transform(str.begin(), str.end(), str.begin(), ::toupper);
29 return str; 31 return str;
30} 32}
@@ -541,3 +543,5 @@ std::string UTF16ToUTF8(const std::wstring& input)
541} 543}
542 544
543#endif 545#endif
546
547}
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 @@
12 12
13#include "common/common.h" 13#include "common/common.h"
14 14
15/// Make a string lowercase 15namespace Common {
16 16
17std::string LowerStr(std::string str); 17/// Make a string lowercase
18std::string ToLower(std::string str);
18 19
19/// Make a string uppercase 20/// Make a string uppercase
20std::string UpperStr(std::string str); 21std::string ToUpper(std::string str);
21 22
22std::string StringFromFormat(const char* format, ...); 23std::string StringFromFormat(const char* format, ...);
23// Cheap! 24// Cheap!
@@ -112,3 +113,5 @@ inline std::string UTF8ToTStr(const std::string& str)
112#endif 113#endif
113 114
114#endif 115#endif
116
117}