|
|
@@ -30,7 +30,7 @@
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
-#ifdef WIN32
|
|
|
+#ifdef _WIN32
|
|
|
#include <Windows.h>
|
|
|
#include <Shellapi.h>
|
|
|
#include <direct.h>
|
|
|
@@ -69,7 +69,7 @@ bool FileSystem::SetCurrentDir(const String& pathName)
|
|
|
LOGERROR("Access denied to " + pathName);
|
|
|
return false;
|
|
|
}
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
if (SetCurrentDirectory(GetNativePath(pathName).CString()) == FALSE)
|
|
|
{
|
|
|
LOGERROR("Failed to change directory to " + pathName);
|
|
|
@@ -93,7 +93,7 @@ bool FileSystem::CreateDir(const String& pathName)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
bool success = (CreateDirectory(GetNativePath(RemoveTrailingSlash(pathName)).CString(), 0) == TRUE) ||
|
|
|
(GetLastError() == ERROR_ALREADY_EXISTS);
|
|
|
#else
|
|
|
@@ -121,7 +121,7 @@ int FileSystem::SystemCommand(const String& commandLine)
|
|
|
|
|
|
int FileSystem::SystemRun(const String& fileName, const Vector<String>& arguments)
|
|
|
{
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
if (allowedPaths_.Empty())
|
|
|
{
|
|
|
String fixedFileName = GetNativePath(fileName);
|
|
|
@@ -148,7 +148,7 @@ int FileSystem::SystemRun(const String& fileName, const Vector<String>& argument
|
|
|
|
|
|
bool FileSystem::SystemOpen(const String& fileName, const String& mode)
|
|
|
{
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
if (allowedPaths_.Empty())
|
|
|
{
|
|
|
if ((!FileExists(fileName)) && (!DirExists(fileName)))
|
|
|
@@ -235,7 +235,7 @@ String FileSystem::GetCurrentDir()
|
|
|
char path[MAX_PATH];
|
|
|
path[0] = 0;
|
|
|
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
GetCurrentDirectory(MAX_PATH, path);
|
|
|
#else
|
|
|
getcwd(path, MAX_PATH);
|
|
|
@@ -273,7 +273,7 @@ bool FileSystem::FileExists(const String& fileName)
|
|
|
return false;
|
|
|
|
|
|
String fixedName = GetNativePath(RemoveTrailingSlash(fileName));
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
DWORD attributes = GetFileAttributes(fixedName.CString());
|
|
|
if ((attributes == INVALID_FILE_ATTRIBUTES) || (attributes & FILE_ATTRIBUTE_DIRECTORY))
|
|
|
return false;
|
|
|
@@ -292,7 +292,7 @@ bool FileSystem::DirExists(const String& pathName)
|
|
|
return false;
|
|
|
|
|
|
String fixedName = GetNativePath(RemoveTrailingSlash(pathName));
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
DWORD attributes = GetFileAttributes(fixedName.CString());
|
|
|
if ((attributes == INVALID_FILE_ATTRIBUTES) || (!(attributes & FILE_ATTRIBUTE_DIRECTORY)))
|
|
|
return false;
|
|
|
@@ -320,7 +320,7 @@ String FileSystem::GetProgramDir()
|
|
|
{
|
|
|
char exeName[MAX_PATH];
|
|
|
exeName[0] = 0;
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
GetModuleFileName(0, exeName, MAX_PATH);
|
|
|
#else
|
|
|
unsigned pid = getpid();
|
|
|
@@ -335,7 +335,7 @@ String FileSystem::GetUserDocumentsDir()
|
|
|
{
|
|
|
char pathName[MAX_PATH];
|
|
|
pathName[0] = 0;
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
SHGetSpecialFolderPath(0, pathName, CSIDL_PERSONAL, 0);
|
|
|
#else
|
|
|
strcpy(pathName, getenv("HOME"));
|
|
|
@@ -360,7 +360,7 @@ void FileSystem::ScanDirInternal(Vector<String>& result, String path, const Stri
|
|
|
if (path.Length() > startPath.Length())
|
|
|
deltaPath = path.Substring(startPath.Length());
|
|
|
|
|
|
- #ifdef WIN32
|
|
|
+ #ifdef _WIN32
|
|
|
WIN32_FIND_DATA info;
|
|
|
HANDLE handle = FindFirstFile(pathAndFilter.CString(), &info);
|
|
|
if (handle != INVALID_HANDLE_VALUE)
|
|
|
@@ -509,7 +509,7 @@ String GetInternalPath(const String& pathName)
|
|
|
|
|
|
String GetNativePath(const String& pathName)
|
|
|
{
|
|
|
-#ifdef WIN32
|
|
|
+#ifdef _WIN32
|
|
|
String ret = pathName;
|
|
|
ret.Replace('/', '\\');
|
|
|
return ret;
|