|
@@ -71,7 +71,7 @@ bool FileSystem::SetCurrentDir(const String& pathName)
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
- if (SetCurrentDirectory(GetNativePath(pathName).CString()) == FALSE)
|
|
|
|
|
|
|
+ if (SetCurrentDirectoryW(WString(GetNativePath(pathName)).CString()) == FALSE)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Failed to change directory to " + pathName);
|
|
LOGERROR("Failed to change directory to " + pathName);
|
|
|
return false;
|
|
return false;
|
|
@@ -96,7 +96,7 @@ bool FileSystem::CreateDir(const String& pathName)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
- bool success = (CreateDirectory(GetNativePath(RemoveTrailingSlash(pathName)).CString(), 0) == TRUE) ||
|
|
|
|
|
|
|
+ bool success = (CreateDirectoryW(WString(GetNativePath(RemoveTrailingSlash(pathName))).CString(), 0) == TRUE) ||
|
|
|
(GetLastError() == ERROR_ALREADY_EXISTS);
|
|
(GetLastError() == ERROR_ALREADY_EXISTS);
|
|
|
#else
|
|
#else
|
|
|
bool success = mkdir(GetNativePath(RemoveTrailingSlash(pathName)).CString(), S_IRWXU) == 0 || errno == EEXIST;
|
|
bool success = mkdir(GetNativePath(RemoveTrailingSlash(pathName)).CString(), S_IRWXU) == 0 || errno == EEXIST;
|
|
@@ -179,8 +179,8 @@ bool FileSystem::SystemOpen(const String& fileName, const String& mode)
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- bool success = (int)ShellExecute(0, !mode.Empty() ? (char*)mode.CString() : 0,
|
|
|
|
|
- (char*)GetNativePath(fileName).CString(), 0, 0, SW_SHOW) > 32;
|
|
|
|
|
|
|
+ bool success = (int)ShellExecuteW(0, !mode.Empty() ? WString(mode).CString() : 0,
|
|
|
|
|
+ WString(GetNativePath(fileName)).CString(), 0, 0, SW_SHOW) > 32;
|
|
|
if (!success)
|
|
if (!success)
|
|
|
LOGERROR("Failed to open " + fileName + " externally");
|
|
LOGERROR("Failed to open " + fileName + " externally");
|
|
|
return success;
|
|
return success;
|
|
@@ -253,16 +253,17 @@ bool FileSystem::Delete(const String& fileName)
|
|
|
|
|
|
|
|
String FileSystem::GetCurrentDir()
|
|
String FileSystem::GetCurrentDir()
|
|
|
{
|
|
{
|
|
|
- char path[MAX_PATH];
|
|
|
|
|
- path[0] = 0;
|
|
|
|
|
-
|
|
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
- GetCurrentDirectory(MAX_PATH, path);
|
|
|
|
|
|
|
+ wchar_t path[MAX_PATH];
|
|
|
|
|
+ path[0] = 0;
|
|
|
|
|
+ GetCurrentDirectoryW(MAX_PATH, path);
|
|
|
|
|
+ return AddTrailingSlash(String(path));
|
|
|
#else
|
|
#else
|
|
|
|
|
+ char path[MAX_PATH];
|
|
|
|
|
+ path[0] = 0;
|
|
|
getcwd(path, MAX_PATH);
|
|
getcwd(path, MAX_PATH);
|
|
|
- #endif
|
|
|
|
|
-
|
|
|
|
|
return AddTrailingSlash(String(path));
|
|
return AddTrailingSlash(String(path));
|
|
|
|
|
+ #endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool FileSystem::CheckAccess(const String& pathName)
|
|
bool FileSystem::CheckAccess(const String& pathName)
|
|
@@ -296,7 +297,7 @@ bool FileSystem::FileExists(const String& fileName)
|
|
|
String fixedName = GetNativePath(RemoveTrailingSlash(fileName));
|
|
String fixedName = GetNativePath(RemoveTrailingSlash(fileName));
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
- DWORD attributes = GetFileAttributes(fixedName.CString());
|
|
|
|
|
|
|
+ DWORD attributes = GetFileAttributesW(WString(fixedName).CString());
|
|
|
if (attributes == INVALID_FILE_ATTRIBUTES || attributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
if (attributes == INVALID_FILE_ATTRIBUTES || attributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
return false;
|
|
return false;
|
|
|
#else
|
|
#else
|
|
@@ -316,7 +317,7 @@ bool FileSystem::DirExists(const String& pathName)
|
|
|
String fixedName = GetNativePath(RemoveTrailingSlash(pathName));
|
|
String fixedName = GetNativePath(RemoveTrailingSlash(pathName));
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
- DWORD attributes = GetFileAttributes(fixedName.CString());
|
|
|
|
|
|
|
+ DWORD attributes = GetFileAttributes(WString(fixedName).CString());
|
|
|
if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY))
|
|
if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY))
|
|
|
return false;
|
|
return false;
|
|
|
#else
|
|
#else
|
|
@@ -341,37 +342,42 @@ void FileSystem::ScanDir(Vector<String>& result, const String& pathName, const S
|
|
|
|
|
|
|
|
String FileSystem::GetProgramDir()
|
|
String FileSystem::GetProgramDir()
|
|
|
{
|
|
{
|
|
|
- char exeName[MAX_PATH];
|
|
|
|
|
- memset(exeName, 0, MAX_PATH);
|
|
|
|
|
-
|
|
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
- GetModuleFileName(0, exeName, MAX_PATH);
|
|
|
|
|
|
|
+ wchar_t exeName[MAX_PATH];
|
|
|
|
|
+ exeName[0] = 0;
|
|
|
|
|
+ GetModuleFileNameW(0, exeName, MAX_PATH);
|
|
|
|
|
+ return GetPath(String(exeName));
|
|
|
#endif
|
|
#endif
|
|
|
#ifdef __APPLE__
|
|
#ifdef __APPLE__
|
|
|
|
|
+ char exeName[MAX_PATH];
|
|
|
|
|
+ memset(exeName, 0, MAX_PATH);
|
|
|
unsigned size = MAX_PATH;
|
|
unsigned size = MAX_PATH;
|
|
|
_NSGetExecutablePath(exeName, &size);
|
|
_NSGetExecutablePath(exeName, &size);
|
|
|
|
|
+ return GetPath(String(exeName));
|
|
|
#endif
|
|
#endif
|
|
|
#ifdef __linux__
|
|
#ifdef __linux__
|
|
|
|
|
+ char exeName[MAX_PATH];
|
|
|
|
|
+ memset(exeName, 0, MAX_PATH);
|
|
|
pid_t pid = getpid();
|
|
pid_t pid = getpid();
|
|
|
String link = "/proc/" + String(pid) + "/exe";
|
|
String link = "/proc/" + String(pid) + "/exe";
|
|
|
readlink(link.CString(), exeName, MAX_PATH);
|
|
readlink(link.CString(), exeName, MAX_PATH);
|
|
|
- #endif
|
|
|
|
|
-
|
|
|
|
|
return GetPath(String(exeName));
|
|
return GetPath(String(exeName));
|
|
|
|
|
+ #endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String FileSystem::GetUserDocumentsDir()
|
|
String FileSystem::GetUserDocumentsDir()
|
|
|
{
|
|
{
|
|
|
- char pathName[MAX_PATH];
|
|
|
|
|
- pathName[0] = 0;
|
|
|
|
|
-
|
|
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
- SHGetSpecialFolderPath(0, pathName, CSIDL_PERSONAL, 0);
|
|
|
|
|
|
|
+ wchar_t pathName[MAX_PATH];
|
|
|
|
|
+ pathName[0] = 0;
|
|
|
|
|
+ SHGetSpecialFolderPathW(0, pathName, CSIDL_PERSONAL, 0);
|
|
|
|
|
+ return AddTrailingSlash(String(pathName));
|
|
|
#else
|
|
#else
|
|
|
|
|
+ char pathName[MAX_PATH];
|
|
|
|
|
+ pathName[0] = 0;
|
|
|
strcpy(pathName, getenv("HOME"));
|
|
strcpy(pathName, getenv("HOME"));
|
|
|
- #endif
|
|
|
|
|
-
|
|
|
|
|
return AddTrailingSlash(String(pathName));
|
|
return AddTrailingSlash(String(pathName));
|
|
|
|
|
+ #endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void FileSystem::RegisterPath(const String& pathName)
|
|
void FileSystem::RegisterPath(const String& pathName)
|
|
@@ -393,7 +399,7 @@ void FileSystem::ScanDirInternal(Vector<String>& result, String path, const Stri
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
|
String pathAndFilter = GetNativePath(path + filter);
|
|
String pathAndFilter = GetNativePath(path + filter);
|
|
|
WIN32_FIND_DATA info;
|
|
WIN32_FIND_DATA info;
|
|
|
- HANDLE handle = FindFirstFile(pathAndFilter.CString(), &info);
|
|
|
|
|
|
|
+ HANDLE handle = FindFirstFileW(WString(pathAndFilter).CString(), &info);
|
|
|
if (handle != INVALID_HANDLE_VALUE)
|
|
if (handle != INVALID_HANDLE_VALUE)
|
|
|
{
|
|
{
|
|
|
do
|
|
do
|