mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 08:15:33 +01:00
Fix "Common" to build with "Unicode" project setting.
This commit is contained in:
parent
ea75577278
commit
69f7671ee8
@ -44,7 +44,7 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <memory> // for std::unique_ptr
|
#include <memory> // for std::unique_ptr
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include "StringUtil.h"
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <IOKit/IOBSD.h>
|
#include <IOKit/IOBSD.h>
|
||||||
@ -25,7 +26,7 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// takes a root drive path, returns true if it is a cdrom drive
|
// takes a root drive path, returns true if it is a cdrom drive
|
||||||
bool is_cdrom(const char drive[])
|
bool is_cdrom(const TCHAR* drive)
|
||||||
{
|
{
|
||||||
return (DRIVE_CDROM == GetDriveType(drive));
|
return (DRIVE_CDROM == GetDriveType(drive));
|
||||||
}
|
}
|
||||||
@ -36,15 +37,15 @@ std::vector<std::string> cdio_get_devices()
|
|||||||
std::vector<std::string> drives;
|
std::vector<std::string> drives;
|
||||||
|
|
||||||
const DWORD buffsize = GetLogicalDriveStrings(0, NULL);
|
const DWORD buffsize = GetLogicalDriveStrings(0, NULL);
|
||||||
std::unique_ptr<char[]> buff(new char[buffsize]);
|
std::vector<TCHAR> buff(buffsize);
|
||||||
if (GetLogicalDriveStrings(buffsize, buff.get()) == buffsize - 1)
|
if (GetLogicalDriveStrings(buffsize, buff.data()) == buffsize - 1)
|
||||||
{
|
{
|
||||||
const char* drive = buff.get();
|
auto drive = buff.data();
|
||||||
while (*drive)
|
while (*drive)
|
||||||
{
|
{
|
||||||
if (is_cdrom(drive))
|
if (is_cdrom(drive))
|
||||||
{
|
{
|
||||||
std::string str(drive);
|
std::string str(TStrToUTF8(drive));
|
||||||
str.pop_back(); // we don't want the final backslash
|
str.pop_back(); // we don't want the final backslash
|
||||||
drives.push_back(std::move(str));
|
drives.push_back(std::move(str));
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title
|
|||||||
// Save the window handle that AllocConsole() created
|
// Save the window handle that AllocConsole() created
|
||||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
// Set the console window title
|
// Set the console window title
|
||||||
SetConsoleTitle(Title);
|
SetConsoleTitle(UTF8ToTStr(Title).c_str());
|
||||||
// Set letter space
|
// Set letter space
|
||||||
LetterSpace(80, 4000);
|
LetterSpace(80, 4000);
|
||||||
//MoveWindow(GetConsoleWindow(), 200,200, 800,800, true);
|
//MoveWindow(GetConsoleWindow(), 200,200, 800,800, true);
|
||||||
@ -195,7 +195,7 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
|
|||||||
|
|
||||||
static const int MAX_BYTES = 1024 * 16;
|
static const int MAX_BYTES = 1024 * 16;
|
||||||
|
|
||||||
std::vector<std::array<CHAR, MAX_BYTES>> Str;
|
std::vector<std::array<TCHAR, MAX_BYTES>> Str;
|
||||||
std::vector<std::array<WORD, MAX_BYTES>> Attr;
|
std::vector<std::array<WORD, MAX_BYTES>> Attr;
|
||||||
|
|
||||||
// ReadConsoleOutputAttribute seems to have a limit at this level
|
// ReadConsoleOutputAttribute seems to have a limit at this level
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "ExtendedTrace.h"
|
#include "ExtendedTrace.h"
|
||||||
|
#include "StringUtil.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
@ -274,13 +275,21 @@ static BOOL GetSourceInfoFromAddress( UINT address, LPTSTR lpszSourceInfo )
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file )
|
void PrintFunctionAndSourceInfo(FILE* file, const STACKFRAME& callstack)
|
||||||
|
{
|
||||||
|
TCHAR symInfo[BUFFERSIZE] = _T("?");
|
||||||
|
TCHAR srcInfo[BUFFERSIZE] = _T("?");
|
||||||
|
|
||||||
|
GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo);
|
||||||
|
GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo);
|
||||||
|
etfprint(file, " " + TStrToUTF8(srcInfo) + " : " + TStrToUTF8(symInfo) + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file )
|
||||||
{
|
{
|
||||||
STACKFRAME callStack;
|
STACKFRAME callStack;
|
||||||
BOOL bResult;
|
BOOL bResult;
|
||||||
CONTEXT context;
|
CONTEXT context;
|
||||||
TCHAR symInfo[BUFFERSIZE] = _T("?");
|
|
||||||
TCHAR srcInfo[BUFFERSIZE] = _T("?");
|
|
||||||
HANDLE hProcess = GetCurrentProcess();
|
HANDLE hProcess = GetCurrentProcess();
|
||||||
|
|
||||||
// If it's not this thread, let's suspend it, and resume it at the end
|
// If it's not this thread, let's suspend it, and resume it at the end
|
||||||
@ -318,9 +327,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file )
|
|||||||
etfprint(file, "Call stack info: \n");
|
etfprint(file, "Call stack info: \n");
|
||||||
etfprint(file, lpszMessage);
|
etfprint(file, lpszMessage);
|
||||||
|
|
||||||
GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo );
|
PrintFunctionAndSourceInfo(file, callStack);
|
||||||
GetSourceInfoFromAddress( (ULONG)callStack.AddrPC.Offset, srcInfo );
|
|
||||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
|
||||||
|
|
||||||
for( ULONG index = 0; ; index++ )
|
for( ULONG index = 0; ; index++ )
|
||||||
{
|
{
|
||||||
@ -341,9 +348,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file )
|
|||||||
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo );
|
PrintFunctionAndSourceInfo(file, callStack);
|
||||||
GetSourceInfoFromAddress( (UINT)callStack.AddrPC.Offset, srcInfo );
|
|
||||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,19 +356,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file )
|
|||||||
ResumeThread( hThread );
|
ResumeThread( hThread );
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackTrace( HANDLE hThread, wchar_t const*lpszMessage, FILE *file, DWORD eip, DWORD esp, DWORD ebp )
|
void StackTrace(HANDLE hThread, const char* lpszMessage, FILE *file, DWORD eip, DWORD esp, DWORD ebp )
|
||||||
{
|
|
||||||
// TODO: remove when Common builds as unicode
|
|
||||||
size_t origsize = wcslen(lpszMessage) + 1;
|
|
||||||
const size_t newsize = 100;
|
|
||||||
size_t convertedChars = 0;
|
|
||||||
char nstring[newsize];
|
|
||||||
wcstombs_s(&convertedChars, nstring, origsize, lpszMessage, _TRUNCATE);
|
|
||||||
|
|
||||||
StackTrace(hThread, nstring, file, eip, esp, ebp );
|
|
||||||
}
|
|
||||||
|
|
||||||
void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWORD esp, DWORD ebp )
|
|
||||||
{
|
{
|
||||||
STACKFRAME callStack;
|
STACKFRAME callStack;
|
||||||
BOOL bResult;
|
BOOL bResult;
|
||||||
@ -391,9 +384,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWO
|
|||||||
etfprint(file, "Call stack info: \n");
|
etfprint(file, "Call stack info: \n");
|
||||||
etfprint(file, lpszMessage);
|
etfprint(file, lpszMessage);
|
||||||
|
|
||||||
GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo );
|
PrintFunctionAndSourceInfo(file, callStack);
|
||||||
GetSourceInfoFromAddress( (UINT)callStack.AddrPC.Offset, srcInfo );
|
|
||||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
|
||||||
|
|
||||||
for( ULONG index = 0; ; index++ )
|
for( ULONG index = 0; ; index++ )
|
||||||
{
|
{
|
||||||
@ -414,10 +405,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWO
|
|||||||
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo );
|
PrintFunctionAndSourceInfo(file, callStack);
|
||||||
GetSourceInfoFromAddress( (UINT)callStack.AddrPC.Offset, srcInfo );
|
|
||||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hThread != GetCurrentThread() )
|
if ( hThread != GetCurrentThread() )
|
||||||
@ -426,7 +414,8 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWO
|
|||||||
|
|
||||||
char g_uefbuf[2048];
|
char g_uefbuf[2048];
|
||||||
|
|
||||||
void etfprintf(FILE *file, const char *format, ...) {
|
void etfprintf(FILE *file, const char *format, ...)
|
||||||
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
int len = vsprintf(g_uefbuf, format, ap);
|
int len = vsprintf(g_uefbuf, format, ap);
|
||||||
@ -434,7 +423,8 @@ void etfprintf(FILE *file, const char *format, ...) {
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void etfprint(FILE *file, const std::string &text) {
|
void etfprint(FILE *file, const std::string &text)
|
||||||
|
{
|
||||||
size_t len = text.length();
|
size_t len = text.length();
|
||||||
fwrite(text.data(), 1, len, file);
|
fwrite(text.data(), 1, len, file);
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,14 @@
|
|||||||
|
|
||||||
#define EXTENDEDTRACEINITIALIZE( IniSymbolPath ) InitSymInfo( IniSymbolPath )
|
#define EXTENDEDTRACEINITIALIZE( IniSymbolPath ) InitSymInfo( IniSymbolPath )
|
||||||
#define EXTENDEDTRACEUNINITIALIZE() UninitSymInfo()
|
#define EXTENDEDTRACEUNINITIALIZE() UninitSymInfo()
|
||||||
#define STACKTRACE(file) StackTrace( GetCurrentThread(), _T(""), file)
|
#define STACKTRACE(file) StackTrace( GetCurrentThread(), "", file)
|
||||||
#define STACKTRACE2(file, eip, esp, ebp) StackTrace(GetCurrentThread(), _T(""), file, eip, esp, ebp)
|
#define STACKTRACE2(file, eip, esp, ebp) StackTrace(GetCurrentThread(), "", file, eip, esp, ebp)
|
||||||
// class File;
|
// class File;
|
||||||
|
|
||||||
BOOL InitSymInfo( PCSTR );
|
BOOL InitSymInfo( PCSTR );
|
||||||
BOOL UninitSymInfo();
|
BOOL UninitSymInfo();
|
||||||
void StackTrace( HANDLE, LPCTSTR, FILE *file);
|
void StackTrace(HANDLE, char const* msg, FILE *file);
|
||||||
void StackTrace( HANDLE, LPCTSTR, FILE *file, DWORD eip, DWORD esp, DWORD ebp);
|
void StackTrace(HANDLE, char const* msg, FILE *file, DWORD eip, DWORD esp, DWORD ebp);
|
||||||
void StackTrace( HANDLE hThread, wchar_t const* lpszMessage, FILE *file, DWORD eip, DWORD esp, DWORD ebp);
|
|
||||||
|
|
||||||
// functions by Masken
|
// functions by Masken
|
||||||
void etfprintf(FILE *file, const char *format, ...);
|
void etfprintf(FILE *file, const char *format, ...);
|
||||||
|
@ -51,7 +51,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
|
|||||||
BuildCompleteFilename(GCMSearchPath, _strPath, _searchString);
|
BuildCompleteFilename(GCMSearchPath, _strPath, _searchString);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WIN32_FIND_DATA findData;
|
WIN32_FIND_DATA findData;
|
||||||
HANDLE FindFirst = FindFirstFile(GCMSearchPath.c_str(), &findData);
|
HANDLE FindFirst = FindFirstFile(UTF8ToTStr(GCMSearchPath).c_str(), &findData);
|
||||||
|
|
||||||
if (FindFirst != INVALID_HANDLE_VALUE)
|
if (FindFirst != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
|
|||||||
if (findData.cFileName[0] != '.')
|
if (findData.cFileName[0] != '.')
|
||||||
{
|
{
|
||||||
std::string strFilename;
|
std::string strFilename;
|
||||||
BuildCompleteFilename(strFilename, _strPath, findData.cFileName);
|
BuildCompleteFilename(strFilename, _strPath, TStrToUTF8(findData.cFileName));
|
||||||
m_FileNames.push_back(strFilename);
|
m_FileNames.push_back(strFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,6 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const CFileSearch::XStringVector& CFileSearch::GetFileNames() const
|
const CFileSearch::XStringVector& CFileSearch::GetFileNames() const
|
||||||
{
|
{
|
||||||
return m_FileNames;
|
return m_FileNames;
|
||||||
|
@ -41,10 +41,11 @@
|
|||||||
#include <CoreFoundation/CFBundle.h>
|
#include <CoreFoundation/CFBundle.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "StringUtil.h"
|
||||||
|
|
||||||
#ifndef S_ISDIR
|
#ifndef S_ISDIR
|
||||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||||
#endif
|
#endif
|
||||||
@ -127,7 +128,7 @@ bool Delete(const std::string &filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!DeleteFile(filename.c_str()))
|
if (!DeleteFile(UTF8ToTStr(filename).c_str()))
|
||||||
{
|
{
|
||||||
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
|
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
|
||||||
filename.c_str(), GetLastErrorMsg());
|
filename.c_str(), GetLastErrorMsg());
|
||||||
@ -149,7 +150,7 @@ bool CreateDir(const std::string &path)
|
|||||||
{
|
{
|
||||||
INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str());
|
INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str());
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (::CreateDirectory(path.c_str(), NULL))
|
if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL))
|
||||||
return true;
|
return true;
|
||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
if (error == ERROR_ALREADY_EXISTS)
|
if (error == ERROR_ALREADY_EXISTS)
|
||||||
@ -228,7 +229,7 @@ bool DeleteDir(const std::string &filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (::RemoveDirectory(filename.c_str()))
|
if (::RemoveDirectory(UTF8ToTStr(filename).c_str()))
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
if (rmdir(filename.c_str()) == 0)
|
if (rmdir(filename.c_str()) == 0)
|
||||||
@ -257,7 +258,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
|
|||||||
INFO_LOG(COMMON, "Copy: %s --> %s",
|
INFO_LOG(COMMON, "Copy: %s --> %s",
|
||||||
srcFilename.c_str(), destFilename.c_str());
|
srcFilename.c_str(), destFilename.c_str());
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (CopyFile(srcFilename.c_str(), destFilename.c_str(), FALSE))
|
if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s",
|
ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s",
|
||||||
@ -413,7 +414,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
|
|||||||
// Find the first file in the directory.
|
// Find the first file in the directory.
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
|
|
||||||
HANDLE hFind = FindFirstFile((directory + "\\*").c_str(), &ffd);
|
HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd);
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
@ -423,7 +424,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
FSTEntry entry;
|
FSTEntry entry;
|
||||||
const std::string virtualName(ffd.cFileName);
|
const std::string virtualName(TStrToUTF8(ffd.cFileName));
|
||||||
#else
|
#else
|
||||||
struct dirent dirent, *result = NULL;
|
struct dirent dirent, *result = NULL;
|
||||||
|
|
||||||
@ -480,7 +481,7 @@ bool DeleteDirRecursively(const std::string &directory)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Find the first file in the directory.
|
// Find the first file in the directory.
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
HANDLE hFind = FindFirstFile((directory + "\\*").c_str(), &ffd);
|
HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd);
|
||||||
|
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -491,7 +492,7 @@ bool DeleteDirRecursively(const std::string &directory)
|
|||||||
// windows loop
|
// windows loop
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const std::string virtualName = ffd.cFileName;
|
const std::string virtualName(TStrToUTF8(ffd.cFileName));
|
||||||
#else
|
#else
|
||||||
struct dirent dirent, *result = NULL;
|
struct dirent dirent, *result = NULL;
|
||||||
DIR *dirp = opendir(directory.c_str());
|
DIR *dirp = opendir(directory.c_str());
|
||||||
|
@ -31,7 +31,7 @@ const char* GetLastErrorMsg()
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static __declspec(thread) char err_str[buff_size] = {};
|
static __declspec(thread) char err_str[buff_size] = {};
|
||||||
|
|
||||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
|
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
err_str, buff_size, NULL);
|
err_str, buff_size, NULL);
|
||||||
#else
|
#else
|
||||||
|
@ -106,7 +106,7 @@ bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int S
|
|||||||
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
|
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
|
||||||
if (Style == WARNING) STYLE = MB_ICONWARNING;
|
if (Style == WARNING) STYLE = MB_ICONWARNING;
|
||||||
|
|
||||||
return IDYES == MessageBox(0, text, caption, STYLE | (yes_no ? MB_YESNO : MB_OK));
|
return IDYES == MessageBox(0, UTF8ToTStr(text).c_str(), UTF8ToTStr(caption).c_str(), STYLE | (yes_no ? MB_YESNO : MB_OK));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
printf("%s\n", text);
|
printf("%s\n", text);
|
||||||
|
@ -102,6 +102,20 @@ std::string UriEncode(const std::string & sSrc);
|
|||||||
std::string UTF16ToUTF8(const std::wstring& str);
|
std::string UTF16ToUTF8(const std::wstring& str);
|
||||||
std::wstring UTF8ToUTF16(const std::string& str);
|
std::wstring UTF8ToUTF16(const std::string& str);
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
inline std::string TStrToUTF8(const std::wstring& str)
|
||||||
|
{ return UTF16ToUTF8(str); }
|
||||||
|
|
||||||
|
inline std::wstring UTF8ToTStr(const std::string& str)
|
||||||
|
{ return UTF8ToUTF16(str); }
|
||||||
|
#else
|
||||||
|
inline std::string TStrToUTF8(const std::string& str)
|
||||||
|
{ return str; }
|
||||||
|
|
||||||
|
inline std::string UTF8ToTStr(const std::string& str)
|
||||||
|
{ return str; }
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _STRINGUTIL_H_
|
#endif // _STRINGUTIL_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user