*: check defined(_WIN32) instead of defined(WIN32)
Only _WIN32 is defined by the compiler, and WIN32 is not standardized and may be missing. Closes #169
This commit is contained in:
@@ -26,13 +26,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <fileapi.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
static inline constexpr uint64_t
|
||||
ConstructUint64(DWORD lo, DWORD hi)
|
||||
@@ -54,7 +54,7 @@ class FileInfo {
|
||||
bool follow_symlinks);
|
||||
friend class FileReader;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||
#else
|
||||
struct stat st;
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
FileInfo(Path path, bool follow_symlinks=true) {
|
||||
if (!GetFileInfo(path, *this, follow_symlinks)) {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
throw FormatLastError("Failed to access %s",
|
||||
path.ToUTF8().c_str());
|
||||
#else
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
}
|
||||
|
||||
bool IsRegular() const {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
return (data.dwFileAttributes &
|
||||
(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE)) == 0;
|
||||
#else
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
bool IsDirectory() const {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
return data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
||||
#else
|
||||
return S_ISDIR(st.st_mode);
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
}
|
||||
|
||||
uint64_t GetSize() const {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
return ConstructUint64(data.nFileSizeLow, data.nFileSizeHigh);
|
||||
#else
|
||||
return st.st_size;
|
||||
@@ -101,14 +101,14 @@ public:
|
||||
}
|
||||
|
||||
time_t GetModificationTime() const {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
return FileTimeToTimeT(data.ftLastWriteTime);
|
||||
#else
|
||||
return st.st_mtime;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
uid_t GetUid() const {
|
||||
return st.st_uid;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
inline bool
|
||||
GetFileInfo(Path path, FileInfo &info, bool follow_symlinks=true)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
(void)follow_symlinks;
|
||||
return GetFileAttributesEx(path.c_str(), GetFileExInfoStandard,
|
||||
&info.data);
|
||||
|
||||
Reference in New Issue
Block a user