Commit 92375f75 authored by mercury233's avatar mercury233 Committed by DailyShana

use windows api instead of c runtime library in myfilesystem.h (#2160)

parent e2d4af84
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
#include <functional> #include <functional>
#include "bufferio.h" #include "bufferio.h"
#ifdef _WIN32 #ifndef _WIN32
#include <direct.h>
#include <sys/stat.h>
#else
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
...@@ -20,8 +17,8 @@ ...@@ -20,8 +17,8 @@
class FileSystem { class FileSystem {
public: public:
static bool IsFileExists(const wchar_t* wfile) { static bool IsFileExists(const wchar_t* wfile) {
struct _stat fileStat; DWORD attr = GetFileAttributesW(wfile);
return (_wstat(wfile, &fileStat) == 0) && !(fileStat.st_mode & _S_IFDIR); return attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY);
} }
static bool IsFileExists(const char* file) { static bool IsFileExists(const char* file) {
...@@ -31,8 +28,8 @@ public: ...@@ -31,8 +28,8 @@ public:
} }
static bool IsDirExists(const wchar_t* wdir) { static bool IsDirExists(const wchar_t* wdir) {
struct _stat fileStat; DWORD attr = GetFileAttributesW(wdir);
return (_wstat(wdir, &fileStat) == 0) && (fileStat.st_mode & _S_IFDIR); return attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY);
} }
static bool IsDirExists(const char* dir) { static bool IsDirExists(const char* dir) {
...@@ -42,7 +39,7 @@ public: ...@@ -42,7 +39,7 @@ public:
} }
static bool MakeDir(const wchar_t* wdir) { static bool MakeDir(const wchar_t* wdir) {
return _wmkdir(wdir) == 0; return CreateDirectoryW(wdir, NULL);
} }
static bool MakeDir(const char* dir) { static bool MakeDir(const char* dir) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment