Use Unicode versions of Win32 functions, issue #261
This commit is contained in:
parent
e4dc8ae94b
commit
e7bebba3d3
16 changed files with 91 additions and 86 deletions
|
@ -1806,7 +1806,7 @@ emptyProc CDriverD3D::getWindowProc()
|
||||||
|
|
||||||
IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon)
|
IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon)
|
||||||
{
|
{
|
||||||
switch (::MessageBox (_HWnd, message, title, ((type==retryCancelType)?MB_RETRYCANCEL:
|
switch (::MessageBoxW (_HWnd, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
|
||||||
(type==yesNoCancelType)?MB_YESNOCANCEL:
|
(type==yesNoCancelType)?MB_YESNOCANCEL:
|
||||||
(type==okCancelType)?MB_OKCANCEL:
|
(type==okCancelType)?MB_OKCANCEL:
|
||||||
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:
|
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:
|
||||||
|
|
|
@ -2622,7 +2622,7 @@ IDriver::TMessageBoxId CDriverGL::systemMessageBox (const char* message, const c
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CDriverGL_systemMessageBox)
|
H_AUTO_OGL(CDriverGL_systemMessageBox)
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
switch (::MessageBox (NULL, message, title, ((type==retryCancelType)?MB_RETRYCANCEL:
|
switch (::MessageBoxW (NULL, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
|
||||||
(type==yesNoCancelType)?MB_YESNOCANCEL:
|
(type==yesNoCancelType)?MB_YESNOCANCEL:
|
||||||
(type==okCancelType)?MB_OKCANCEL:
|
(type==okCancelType)?MB_OKCANCEL:
|
||||||
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:
|
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:
|
||||||
|
|
|
@ -199,11 +199,11 @@ bool CCmdArgs::parse(const std::string &args)
|
||||||
std::vector<std::string> argv;
|
std::vector<std::string> argv;
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
char str[4096];
|
wchar_t str[4096];
|
||||||
uint len = GetModuleFileNameA(NULL, str, 4096);
|
uint len = GetModuleFileNameW(NULL, str, 4096);
|
||||||
|
|
||||||
if (len && len < 4096)
|
if (len && len < 4096)
|
||||||
argv.push_back(str);
|
argv.push_back(wideToUtf8(str));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string::size_type pos1 = 0, pos2 = 0;
|
std::string::size_type pos1 = 0, pos2 = 0;
|
||||||
|
|
|
@ -310,9 +310,9 @@ static DWORD __stdcall GetModuleBase(HANDLE hProcess, DWORD dwReturnAddress)
|
||||||
&memoryBasicInfo, sizeof(memoryBasicInfo)))
|
&memoryBasicInfo, sizeof(memoryBasicInfo)))
|
||||||
{
|
{
|
||||||
DWORD cch = 0;
|
DWORD cch = 0;
|
||||||
char szFile[MAX_PATH] = { 0 };
|
wchar_t szFile[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
cch = GetModuleFileNameA((HINSTANCE)memoryBasicInfo.AllocationBase,
|
cch = GetModuleFileNameW((HINSTANCE)memoryBasicInfo.AllocationBase,
|
||||||
szFile, MAX_PATH);
|
szFile, MAX_PATH);
|
||||||
|
|
||||||
if (cch && (lstrcmpA(szFile, "DBFN")== 0))
|
if (cch && (lstrcmpA(szFile, "DBFN")== 0))
|
||||||
|
@ -527,9 +527,9 @@ public:
|
||||||
string progname;
|
string progname;
|
||||||
if(!shortExc.empty() || !longExc.empty())
|
if(!shortExc.empty() || !longExc.empty())
|
||||||
{
|
{
|
||||||
char name[1024];
|
wchar_t name[1024];
|
||||||
GetModuleFileNameA (NULL, name, 1023);
|
GetModuleFileNameW (NULL, name, 1023);
|
||||||
progname = CFile::getFilename(name);
|
progname = CFile::getFilename(wideToUtf8(name));
|
||||||
progname += " ";
|
progname += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,14 +286,14 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
|
||||||
// WARNING: READ THIS !!!!!!!!!!!!!!!! ///////////////////////////
|
// WARNING: READ THIS !!!!!!!!!!!!!!!! ///////////////////////////
|
||||||
// If at the release time, it freezes here, it's a microsoft bug:
|
// If at the release time, it freezes here, it's a microsoft bug:
|
||||||
// http://support.microsoft.com/support/kb/articles/q173/2/60.asp
|
// http://support.microsoft.com/support/kb/articles/q173/2/60.asp
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(str2).c_str());
|
OutputDebugStringW(utf8ToWide(str2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sint count = 0;
|
sint count = 0;
|
||||||
uint n = (uint)strlen(message);
|
uint n = (uint)strlen(message);
|
||||||
std::string s(&str2.c_str()[0], (str2.size() - n));
|
std::string s(&str2.c_str()[0], (str2.size() - n));
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str());
|
OutputDebugStringW(utf8ToWide(s));
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
@ -301,15 +301,15 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
|
||||||
if((n - count) < maxOutString )
|
if((n - count) < maxOutString )
|
||||||
{
|
{
|
||||||
s = std::string(&message[count], (n - count));
|
s = std::string(&message[count], (n - count));
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str());
|
OutputDebugStringW(utf8ToWide(s));
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8("\n").c_str());
|
OutputDebugStringW(L"\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = std::string(&message[count] , count + maxOutString);
|
s = std::string(&message[count] , count + maxOutString);
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str());
|
OutputDebugStringW(utf8ToWide(s));
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8("\n\t\t\t").c_str());
|
OutputDebugStringW(L"\n\t\t\t");
|
||||||
count += maxOutString;
|
count += maxOutString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,13 +323,13 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
|
||||||
if (pos+1000 < args.CallstackAndLog.size ())
|
if (pos+1000 < args.CallstackAndLog.size ())
|
||||||
{
|
{
|
||||||
splited = args.CallstackAndLog.substr (pos, 1000);
|
splited = args.CallstackAndLog.substr (pos, 1000);
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(splited).c_str());
|
OutputDebugStringW(utf8ToWide(splited));
|
||||||
pos += 1000;
|
pos += 1000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
splited = args.CallstackAndLog.substr (pos);
|
splited = args.CallstackAndLog.substr (pos);
|
||||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(splited).c_str());
|
OutputDebugStringW(utf8ToWide(splited));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ NL_LIB_HANDLE nlLoadLibrary(const std::string &libName)
|
||||||
{
|
{
|
||||||
NL_LIB_HANDLE res = 0;
|
NL_LIB_HANDLE res = 0;
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
res = LoadLibrary(libName.c_str());
|
res = LoadLibraryW(utf8ToWide(libName));
|
||||||
#elif defined(NL_OS_UNIX)
|
#elif defined(NL_OS_UNIX)
|
||||||
res = dlopen(libName.c_str(), RTLD_NOW);
|
res = dlopen(libName.c_str(), RTLD_NOW);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -59,9 +59,9 @@ void CLog::setDefaultProcessName ()
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
if ((*_ProcessName).empty())
|
if ((*_ProcessName).empty())
|
||||||
{
|
{
|
||||||
char name[1024];
|
wchar_t name[1024];
|
||||||
GetModuleFileName (NULL, name, 1023);
|
GetModuleFileNameW(NULL, name, 1023);
|
||||||
(*_ProcessName) = CFile::getFilename(name);
|
(*_ProcessName) = CFile::getFilename(wideToUtf8(name));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((*_ProcessName).empty())
|
if ((*_ProcessName).empty())
|
||||||
|
|
|
@ -227,28 +227,28 @@ static void displayCallStack (CLog *log)
|
||||||
|
|
||||||
if (symbolPath.empty())
|
if (symbolPath.empty())
|
||||||
{
|
{
|
||||||
CHAR tmpPath[stringSize];
|
wchar_t tmpPath[stringSize];
|
||||||
|
|
||||||
symbolPath = ".";
|
symbolPath = ".";
|
||||||
|
|
||||||
if (GetEnvironmentVariable ("_NT_SYMBOL_PATH", tmpPath, stringSize))
|
if (GetEnvironmentVariableW (L"_NT_SYMBOL_PATH", tmpPath, stringSize))
|
||||||
{
|
{
|
||||||
symbolPath += ";";
|
symbolPath += ";";
|
||||||
symbolPath += tmpPath;
|
symbolPath += wideToUtf8(tmpPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetEnvironmentVariable ("_NT_ALTERNATE_SYMBOL_PATH", tmpPath, stringSize))
|
if (GetEnvironmentVariableW (L"_NT_ALTERNATE_SYMBOL_PATH", tmpPath, stringSize))
|
||||||
{
|
{
|
||||||
symbolPath += ";";
|
symbolPath += ";";
|
||||||
symbolPath += tmpPath;
|
symbolPath += wideToUtf8(tmpPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetEnvironmentVariable ("SYSTEMROOT", tmpPath, stringSize))
|
if (GetEnvironmentVariableW (L"SYSTEMROOT", tmpPath, stringSize))
|
||||||
{
|
{
|
||||||
symbolPath += ";";
|
symbolPath += ";";
|
||||||
symbolPath += tmpPath;
|
symbolPath += wideToUtf8(tmpPath);
|
||||||
symbolPath += ";";
|
symbolPath += ";";
|
||||||
symbolPath += tmpPath;
|
symbolPath += wideToUtf8(tmpPath);
|
||||||
symbolPath += "\\system32";
|
symbolPath += "\\system32";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -681,11 +681,11 @@ std::string CPath::getCurrentPath ()
|
||||||
|
|
||||||
std::string CFileContainer::getCurrentPath ()
|
std::string CFileContainer::getCurrentPath ()
|
||||||
{
|
{
|
||||||
char buffer [1024];
|
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
return standardizePath(_getcwd(buffer, 1024), false);
|
wchar_t buffer[1024];
|
||||||
|
return standardizePath(wideToUtf8(_wgetcwd(buffer, 1024)), false);
|
||||||
#else
|
#else
|
||||||
|
char buffer [1024];
|
||||||
return standardizePath(getcwd(buffer, 1024), false);
|
return standardizePath(getcwd(buffer, 1024), false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -700,7 +700,7 @@ bool CFileContainer::setCurrentPath (const std::string &path)
|
||||||
int res;
|
int res;
|
||||||
//nldebug("Change current path to '%s' (current path is '%s')", path.c_str(), getCurrentPath().c_str());
|
//nldebug("Change current path to '%s' (current path is '%s')", path.c_str(), getCurrentPath().c_str());
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
res = _chdir(path.c_str());
|
res = _wchdir(utf8ToWide(path));
|
||||||
#else
|
#else
|
||||||
res = chdir(path.c_str());
|
res = chdir(path.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -756,11 +756,11 @@ std::string CFileContainer::getFullPath (const std::string &path, bool addFinalS
|
||||||
|
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
# define dirent WIN32_FIND_DATA
|
# define dirent WIN32_FIND_DATAW
|
||||||
# define DIR void
|
# define DIR void
|
||||||
|
|
||||||
static string sDir;
|
static string sDir;
|
||||||
static WIN32_FIND_DATA findData;
|
static WIN32_FIND_DATAW findData;
|
||||||
static HANDLE hFind;
|
static HANDLE hFind;
|
||||||
|
|
||||||
DIR *opendir (const char *path)
|
DIR *opendir (const char *path)
|
||||||
|
@ -792,13 +792,12 @@ dirent *readdir (DIR *dir)
|
||||||
// first visit in this directory : FindFirstFile()
|
// first visit in this directory : FindFirstFile()
|
||||||
if (hFind == NULL)
|
if (hFind == NULL)
|
||||||
{
|
{
|
||||||
string fullPath = CPath::standardizePath(sDir) + "*";
|
hFind = FindFirstFileW (utf8ToWide(CPath::standardizePath(sDir) + "*"), &findData);
|
||||||
hFind = FindFirstFileA (fullPath.c_str(), &findData);
|
|
||||||
}
|
}
|
||||||
// directory already visited : FindNextFile()
|
// directory already visited : FindNextFile()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!FindNextFileA (hFind, &findData))
|
if (!FindNextFileW (hFind, &findData))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,7 +844,7 @@ string getname (dirent *de)
|
||||||
{
|
{
|
||||||
nlassert (de != NULL);
|
nlassert (de != NULL);
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
return de->cFileName;
|
return wideToUtf8(de->cFileName);
|
||||||
#else
|
#else
|
||||||
return de->d_name;
|
return de->d_name;
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
|
@ -1766,14 +1765,14 @@ std::string CFileContainer::getWindowsDirectory()
|
||||||
nlwarning("not a ms windows platform");
|
nlwarning("not a ms windows platform");
|
||||||
return "";
|
return "";
|
||||||
#else
|
#else
|
||||||
char winDir[MAX_PATH];
|
wchar_t winDir[MAX_PATH];
|
||||||
UINT numChar = ::GetWindowsDirectory(winDir, MAX_PATH);
|
UINT numChar = GetWindowsDirectoryW(winDir, MAX_PATH);
|
||||||
if (numChar > MAX_PATH || numChar == 0)
|
if (numChar > MAX_PATH || numChar == 0)
|
||||||
{
|
{
|
||||||
nlwarning("Couldn't retrieve windows directory");
|
nlwarning("Couldn't retrieve windows directory");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return CPath::standardizePath(winDir);
|
return CPath::standardizePath(wideToUtf8(winDir));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1789,18 +1788,18 @@ std::string CFileContainer::getApplicationDirectory(const std::string &appName,
|
||||||
if (appPath.empty())
|
if (appPath.empty())
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
char buffer[MAX_PATH];
|
wchar_t buffer[MAX_PATH];
|
||||||
#ifdef CSIDL_LOCAL_APPDATA
|
#ifdef CSIDL_LOCAL_APPDATA
|
||||||
if (local)
|
if (local)
|
||||||
{
|
{
|
||||||
SHGetSpecialFolderPathA(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE);
|
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SHGetSpecialFolderPathA(NULL, buffer, CSIDL_APPDATA, TRUE);
|
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE);
|
||||||
}
|
}
|
||||||
appPath = CPath::standardizePath(buffer);
|
appPath = CPath::standardizePath(wideToUtf8(buffer));
|
||||||
#elif defined(NL_OS_MAC)
|
#elif defined(NL_OS_MAC)
|
||||||
appPath = CPath::standardizePath(getenv("HOME"));
|
appPath = CPath::standardizePath(getenv("HOME"));
|
||||||
appPath += "/Library/Application Support/";
|
appPath += "/Library/Application Support/";
|
||||||
|
@ -1918,7 +1917,7 @@ string CFile::getPath (const string &filename)
|
||||||
bool CFile::isDirectory (const string &filename)
|
bool CFile::isDirectory (const string &filename)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
DWORD res = GetFileAttributes(filename.c_str());
|
DWORD res = GetFileAttributesW(utf8ToWide(filename));
|
||||||
if (res == INVALID_FILE_ATTRIBUTES)
|
if (res == INVALID_FILE_ATTRIBUTES)
|
||||||
{
|
{
|
||||||
// nlwarning ("PATH: '%s' is not a valid file or directory name", filename.c_str ());
|
// nlwarning ("PATH: '%s' is not a valid file or directory name", filename.c_str ());
|
||||||
|
@ -1941,7 +1940,7 @@ bool CFile::isDirectory (const string &filename)
|
||||||
bool CFile::isExists (const string &filename)
|
bool CFile::isExists (const string &filename)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
return (GetFileAttributes(filename.c_str()) != INVALID_FILE_ATTRIBUTES);
|
return GetFileAttributesW(utf8ToWide(filename)) != INVALID_FILE_ATTRIBUTES;
|
||||||
#else // NL_OS_WINDOWS
|
#else // NL_OS_WINDOWS
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
return stat (filename.c_str (), &buf) == 0;
|
return stat (filename.c_str (), &buf) == 0;
|
||||||
|
@ -2013,7 +2012,7 @@ uint32 CFile::getFileSize (const std::string &filename)
|
||||||
{
|
{
|
||||||
#if defined (NL_OS_WINDOWS)
|
#if defined (NL_OS_WINDOWS)
|
||||||
struct _stat buf;
|
struct _stat buf;
|
||||||
int result = _stat (filename.c_str (), &buf);
|
int result = _wstat (utf8ToWide(filename), &buf);
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
int result = stat (filename.c_str (), &buf);
|
int result = stat (filename.c_str (), &buf);
|
||||||
|
@ -2064,7 +2063,7 @@ uint32 CFile::getFileModificationDate(const std::string &filename)
|
||||||
// Use the WIN32 API to read the file times in UTC
|
// Use the WIN32 API to read the file times in UTC
|
||||||
|
|
||||||
// create a file handle (this does not open the file)
|
// create a file handle (this does not open the file)
|
||||||
HANDLE h = CreateFile(fn.c_str(), 0, 0, NULL, OPEN_EXISTING, 0, 0);
|
HANDLE h = CreateFileW(utf8ToWide(fn), 0, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||||
if (h == INVALID_HANDLE_VALUE)
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
nlwarning("Can't get modification date on file '%s' : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
|
nlwarning("Can't get modification date on file '%s' : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
|
||||||
|
@ -2134,7 +2133,7 @@ bool CFile::setFileModificationDate(const std::string &filename, uint32 modTime)
|
||||||
// Use the WIN32 API to set the file times in UTC
|
// Use the WIN32 API to set the file times in UTC
|
||||||
|
|
||||||
// create a file handle (this does not open the file)
|
// create a file handle (this does not open the file)
|
||||||
HANDLE h = CreateFile(fn.c_str(), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
HANDLE h = CreateFileW(utf8ToWide(fn), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
||||||
if (h == INVALID_HANDLE_VALUE)
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
nlwarning("Can't set modification date on file '%s' (error accessing file) : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
|
nlwarning("Can't set modification date on file '%s' (error accessing file) : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
|
||||||
|
@ -2219,7 +2218,7 @@ uint32 CFile::getFileCreationDate(const std::string &filename)
|
||||||
|
|
||||||
#if defined (NL_OS_WINDOWS)
|
#if defined (NL_OS_WINDOWS)
|
||||||
struct _stat buf;
|
struct _stat buf;
|
||||||
int result = _stat (fn.c_str (), &buf);
|
int result = _wstat(utf8ToWide(fn), &buf);
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
int result = stat (fn.c_str (), &buf);
|
int result = stat (fn.c_str (), &buf);
|
||||||
|
@ -2353,7 +2352,7 @@ static bool CopyMoveFile(const std::string &dest, const std::string &src, bool c
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
if (MoveFile(ssrc.c_str(), sdest.c_str()) == 0)
|
if (MoveFileW(utf8ToWide(ssrc), utf8ToWide(sdest)) == 0)
|
||||||
{
|
{
|
||||||
sint lastError = NLMISC::getLastError();
|
sint lastError = NLMISC::getLastError();
|
||||||
nlwarning ("PATH: CopyMoveFile error: can't link/move '%s' into '%s', error %u (%s)",
|
nlwarning ("PATH: CopyMoveFile error: can't link/move '%s' into '%s', error %u (%s)",
|
||||||
|
@ -2456,7 +2455,7 @@ bool CFile::moveFile(const std::string &dest, const std::string &src)
|
||||||
bool CFile::createDirectory(const std::string &filename)
|
bool CFile::createDirectory(const std::string &filename)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
return _mkdir(filename.c_str())==0;
|
return _wmkdir(utf8ToWide(filename))==0;
|
||||||
#else
|
#else
|
||||||
// Set full permissions....
|
// Set full permissions....
|
||||||
return mkdir(filename.c_str(), 0xFFFF)==0;
|
return mkdir(filename.c_str(), 0xFFFF)==0;
|
||||||
|
@ -2677,11 +2676,13 @@ bool CPath::isAbsolutePath(const std::string &path)
|
||||||
bool CFile::setRWAccess(const std::string &filename)
|
bool CFile::setRWAccess(const std::string &filename)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
|
wchar_t *wideFile = utf8ToWide(filename);
|
||||||
|
|
||||||
// if the file exists and there's no write access
|
// if the file exists and there's no write access
|
||||||
if (_access (filename.c_str(), 00) == 0 && _access (filename.c_str(), 06) == -1)
|
if (_waccess (wideFile, 00) == 0 && _waccess (wideFile, 06) == -1)
|
||||||
{
|
{
|
||||||
// try to set the read/write access
|
// try to set the read/write access
|
||||||
if (_chmod (filename.c_str(), _S_IREAD | _S_IWRITE) == -1)
|
if (_wchmod (wideFile, _S_IREAD | _S_IWRITE) == -1)
|
||||||
{
|
{
|
||||||
if (INelContext::getInstance().getAlreadyCreateSharedAmongThreads())
|
if (INelContext::getInstance().getAlreadyCreateSharedAmongThreads())
|
||||||
{
|
{
|
||||||
|
|
|
@ -315,19 +315,19 @@ string CSystemUtils::getRegKey(const string &Entry)
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
|
|
||||||
if(RegOpenKeyEx(HKEY_CURRENT_USER, RootKey.c_str(), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, utf8ToWide(RootKey), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD dwType = 0L;
|
DWORD dwType = 0L;
|
||||||
DWORD dwSize = KeyMaxLength;
|
DWORD dwSize = KeyMaxLength;
|
||||||
unsigned char Buffer[KeyMaxLength];
|
unsigned char Buffer[KeyMaxLength];
|
||||||
|
|
||||||
if(RegQueryValueEx(hkey, Entry.c_str(), NULL, &dwType, Buffer, &dwSize) != ERROR_SUCCESS)
|
if (RegQueryValueExW(hkey, utf8ToWide(Entry), NULL, &dwType, Buffer, &dwSize) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
nlwarning("Can't get the reg key '%s'", Entry.c_str());
|
nlwarning("Can't get the reg key '%s'", Entry.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = (char*)Buffer;
|
ret = wideToUtf8(Buffer);
|
||||||
}
|
}
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
}
|
}
|
||||||
|
@ -346,10 +346,12 @@ bool CSystemUtils::setRegKey(const string &ValueName, const string &Value)
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
DWORD dwDisp;
|
DWORD dwDisp;
|
||||||
|
|
||||||
char nstr[] = { 0x00 };
|
wchar_t nstr[] = { 0x00 };
|
||||||
if (RegCreateKeyExA(HKEY_CURRENT_USER, RootKey.c_str(), 0, nstr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
|
if (RegCreateKeyExW(HKEY_CURRENT_USER, utf8ToWide(RootKey), 0, nstr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (RegSetValueExA(hkey, ValueName.c_str(), 0L, REG_SZ, (const BYTE *)Value.c_str(), (DWORD)(Value.size())+1) == ERROR_SUCCESS)
|
ucstring utf16Value = ucstring::makeFromUtf8(Value);
|
||||||
|
DWORD size = (utf16Value.length() + 1) * 2;
|
||||||
|
if (RegSetValueExW(hkey, utf8ToWide(ValueName), 0L, REG_SZ, (const BYTE *)utf16Value.c_str(), size) == ERROR_SUCCESS)
|
||||||
res = true;
|
res = true;
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
}
|
}
|
||||||
|
@ -453,7 +455,7 @@ static void EnumerateUsingDXGI(IDXGIFactory *pDXGIFactory)
|
||||||
{
|
{
|
||||||
SAdapter adapter;
|
SAdapter adapter;
|
||||||
adapter.id = index;
|
adapter.id = index;
|
||||||
adapter.name = ucstring((ucchar*)desc.Description).toUtf8();
|
adapter.name = wideToUtf8(desc.Description);
|
||||||
adapter.memory = desc.DedicatedVideoMemory / 1024;
|
adapter.memory = desc.DedicatedVideoMemory / 1024;
|
||||||
adapter.found = true;
|
adapter.found = true;
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,12 @@ namespace NLMISC
|
||||||
void CWin32Util::localizeWindow(HWND wnd)
|
void CWin32Util::localizeWindow(HWND wnd)
|
||||||
{
|
{
|
||||||
if (!wnd) return;
|
if (!wnd) return;
|
||||||
int textLength = GetWindowTextLength(wnd);
|
sint textLength = GetWindowTextLengthW(wnd);
|
||||||
if (textLength > 0)
|
if (textLength > 0)
|
||||||
{
|
{
|
||||||
std::vector<char> str(textLength + 1);
|
wchar_t str[1024];
|
||||||
GetWindowText(wnd, &str[0], textLength + 1);
|
GetWindowTextW(wnd, str, 1024);
|
||||||
std::string winText(str.begin(), str.end() - 1);
|
std::string winText = wideToUtf8(str);
|
||||||
if (CI18N::hasTranslation(winText))
|
if (CI18N::hasTranslation(winText))
|
||||||
{
|
{
|
||||||
SetWindowTextW(wnd, (const WCHAR *) CI18N::get(winText).c_str());
|
SetWindowTextW(wnd, (const WCHAR *) CI18N::get(winText).c_str());
|
||||||
|
|
|
@ -198,7 +198,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
string str = ucs.toUtf8();
|
string str = ucs.toUtf8();
|
||||||
nlassert (cwd->Log != NULL);
|
nlassert (cwd->Log != NULL);
|
||||||
ICommand::expand (str, *cwd->Log);
|
ICommand::expand (str, *cwd->Log);
|
||||||
SendMessage (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)str.c_str());
|
SendMessageW (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)wText);
|
||||||
|
|
||||||
SendMessage (cwd->_HInputEdit, EM_SETSEL, str.size(), str.size());
|
SendMessage (cwd->_HInputEdit, EM_SETSEL, str.size(), str.size());
|
||||||
|
|
||||||
|
|
|
@ -277,10 +277,10 @@ uint64 CWinThread::getCPUMask()
|
||||||
|
|
||||||
std::string CWinThread::getUserName()
|
std::string CWinThread::getUserName()
|
||||||
{
|
{
|
||||||
char userName[512];
|
wchar_t userName[512];
|
||||||
DWORD size = 512;
|
DWORD size = 512;
|
||||||
GetUserName (userName, &size);
|
GetUserNameW (userName, &size);
|
||||||
return (const char*)userName;
|
return wideToUtf8(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// **** Process
|
// **** Process
|
||||||
|
@ -333,10 +333,10 @@ class CPSAPILib
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef BOOL (WINAPI *EnumProcessesFunPtr)(DWORD *lpidProcess, DWORD cb, DWORD *cbNeeded);
|
typedef BOOL (WINAPI *EnumProcessesFunPtr)(DWORD *lpidProcess, DWORD cb, DWORD *cbNeeded);
|
||||||
typedef DWORD (WINAPI *GetModuleFileNameExAFunPtr)(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);
|
typedef DWORD (WINAPI *GetModuleFileNameExWFunPtr)(HANDLE hProcess, HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
|
||||||
typedef BOOL (WINAPI *EnumProcessModulesFunPtr)(HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded);
|
typedef BOOL (WINAPI *EnumProcessModulesFunPtr)(HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded);
|
||||||
EnumProcessesFunPtr EnumProcesses;
|
EnumProcessesFunPtr EnumProcesses;
|
||||||
GetModuleFileNameExAFunPtr GetModuleFileNameExA;
|
GetModuleFileNameExWFunPtr GetModuleFileNameExW;
|
||||||
EnumProcessModulesFunPtr EnumProcessModules;
|
EnumProcessModulesFunPtr EnumProcessModules;
|
||||||
public:
|
public:
|
||||||
CPSAPILib();
|
CPSAPILib();
|
||||||
|
@ -353,7 +353,7 @@ CPSAPILib::CPSAPILib()
|
||||||
_LoadFailed = false;
|
_LoadFailed = false;
|
||||||
_PSAPILibHandle = NULL;
|
_PSAPILibHandle = NULL;
|
||||||
EnumProcesses = NULL;
|
EnumProcesses = NULL;
|
||||||
GetModuleFileNameExA = NULL;
|
GetModuleFileNameExW = NULL;
|
||||||
EnumProcessModules = NULL;
|
EnumProcessModules = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,10 +381,10 @@ bool CPSAPILib::init()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
EnumProcesses = (EnumProcessesFunPtr) GetProcAddress(_PSAPILibHandle, "EnumProcesses");
|
EnumProcesses = (EnumProcessesFunPtr) GetProcAddress(_PSAPILibHandle, "EnumProcesses");
|
||||||
GetModuleFileNameExA = (GetModuleFileNameExAFunPtr) GetProcAddress(_PSAPILibHandle, "GetModuleFileNameExA");
|
GetModuleFileNameExW = (GetModuleFileNameExWFunPtr) GetProcAddress(_PSAPILibHandle, "GetModuleFileNameExW");
|
||||||
EnumProcessModules = (EnumProcessModulesFunPtr) GetProcAddress(_PSAPILibHandle, "EnumProcessModules");
|
EnumProcessModules = (EnumProcessModulesFunPtr) GetProcAddress(_PSAPILibHandle, "EnumProcessModules");
|
||||||
if (!EnumProcesses ||
|
if (!EnumProcesses ||
|
||||||
!GetModuleFileNameExA ||
|
!GetModuleFileNameExW ||
|
||||||
!EnumProcessModules
|
!EnumProcessModules
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -453,12 +453,12 @@ bool CWinProcess::enumProcessModules(uint32 processId, std::vector<std::string>
|
||||||
}
|
}
|
||||||
moduleNames.clear();
|
moduleNames.clear();
|
||||||
std::vector<std::string> resultModuleNames;
|
std::vector<std::string> resultModuleNames;
|
||||||
char moduleName[MAX_PATH + 1];
|
wchar_t moduleName[MAX_PATH + 1];
|
||||||
for (uint m = 0; m < prcModules.size(); ++m)
|
for (uint m = 0; m < prcModules.size(); ++m)
|
||||||
{
|
{
|
||||||
if (PSAPILib.GetModuleFileNameExA(hProcess, prcModules[m], moduleName, MAX_PATH))
|
if (PSAPILib.GetModuleFileNameExW(hProcess, prcModules[m], moduleName, MAX_PATH))
|
||||||
{
|
{
|
||||||
moduleNames.push_back(moduleName);
|
moduleNames.push_back(wideToUtf8(moduleName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseHandle(hProcess);
|
CloseHandle(hProcess);
|
||||||
|
@ -563,7 +563,7 @@ public:
|
||||||
PROCESS_INFORMATION processInfo;
|
PROCESS_INFORMATION processInfo;
|
||||||
STARTUPINFO startupInfo = {0};
|
STARTUPINFO startupInfo = {0};
|
||||||
startupInfo.cb = sizeof(STARTUPINFO);
|
startupInfo.cb = sizeof(STARTUPINFO);
|
||||||
if (CreateProcess(programName.c_str(), const_cast<LPTSTR>(arguments.c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
|
if (CreateProcessW(programName.c_str(), const_cast<LPTSTR>(arguments.c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
|
||||||
{
|
{
|
||||||
WatchTask = new CProcessWatchTask(processInfo.hProcess);
|
WatchTask = new CProcessWatchTask(processInfo.hProcess);
|
||||||
WatchThread = IThread::create(WatchTask);
|
WatchThread = IThread::create(WatchTask);
|
||||||
|
|
|
@ -3937,13 +3937,15 @@ public:
|
||||||
s += getSystemInformation();
|
s += getSystemInformation();
|
||||||
|
|
||||||
string progname;
|
string progname;
|
||||||
char name[1024] = "";
|
std::string moduleName;
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
GetModuleFileName (NULL, name, 1023);
|
wchar_t name[1024];
|
||||||
|
GetModuleFileNameW(NULL, name, 1023);
|
||||||
|
moduleName = wideToUtf8(name);
|
||||||
#else
|
#else
|
||||||
// TODO for Linux
|
// TODO for Linux
|
||||||
#endif
|
#endif
|
||||||
progname = CFile::getFilename(name);
|
progname = CFile::getFilename(moduleName);
|
||||||
progname += " ";
|
progname += " ";
|
||||||
progname += "Statistic Report";
|
progname += "Statistic Report";
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ bool CXDPFileReader::init(const std::string &sFilename, sint32 nLowerBound, sint
|
||||||
{
|
{
|
||||||
// First open the file with a normal function
|
// First open the file with a normal function
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
int fd = _open(sFilename.c_str(), _O_BINARY | _O_RDONLY);
|
int fd = _wopen(utf8ToWide(sFilename), _O_BINARY | _O_RDONLY);
|
||||||
#else
|
#else
|
||||||
int fd = open(sFilename.c_str(), O_RDONLY);
|
int fd = open(sFilename.c_str(), O_RDONLY);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -84,7 +84,7 @@ static void setPermanentBanFileMarker(const std::string &path, bool on)
|
||||||
// simply touch a file
|
// simply touch a file
|
||||||
COFile f(path);
|
COFile f(path);
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
SetFileAttributes(path.c_str(), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
|
SetFileAttributesW(utf8ToWide(path), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch(const EStream &e)
|
catch(const EStream &e)
|
||||||
|
|
Loading…
Reference in a new issue