*: 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:
@@ -43,7 +43,7 @@ FileOutputStream::FileOutputStream(Path _path, Mode _mode)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
inline void
|
||||
FileOutputStream::OpenCreate(gcc_unused bool visible)
|
||||
@@ -223,7 +223,7 @@ FileOutputStream::Commit()
|
||||
#endif
|
||||
|
||||
if (!Close()) {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
throw FormatLastError("Failed to commit %s",
|
||||
path.ToUTF8().c_str());
|
||||
#else
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#include "system/FileDescriptor.hxx"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,7 @@ class Path;
|
||||
class FileOutputStream final : public OutputStream {
|
||||
const AllocatedPath path;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
HANDLE handle = INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
FileDescriptor fd = FileDescriptor::Undefined();
|
||||
@@ -116,7 +116,7 @@ private:
|
||||
bool Close() {
|
||||
assert(IsDefined());
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
CloseHandle(handle);
|
||||
handle = INVALID_HANDLE_VALUE;
|
||||
return true;
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
bool SeekEOF() {
|
||||
return SetFilePointer(handle, 0, nullptr,
|
||||
FILE_END) != 0xffffffff;
|
||||
@@ -133,7 +133,7 @@ private:
|
||||
#endif
|
||||
|
||||
bool IsDefined() const {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
return handle != INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
return fd.IsDefined();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
FileReader::FileReader(Path _path)
|
||||
:path(_path),
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#include "system/FileDescriptor.hxx"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@ class FileInfo;
|
||||
class FileReader final : public Reader {
|
||||
AllocatedPath path;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
HANDLE handle;
|
||||
#else
|
||||
FileDescriptor fd;
|
||||
@@ -48,7 +48,7 @@ class FileReader final : public Reader {
|
||||
public:
|
||||
explicit FileReader(Path _path);
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
FileReader(FileReader &&other)
|
||||
:path(std::move(other.path)),
|
||||
handle(other.handle) {
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool IsDefined() const {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
return handle != INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
return fd.IsDefined();
|
||||
@@ -78,7 +78,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
FileDescriptor GetFD() const {
|
||||
return fd;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
gcc_pure
|
||||
uint64_t GetSize() const noexcept {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER size;
|
||||
return GetFileSizeEx(handle, &size)
|
||||
? size.QuadPart
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
gcc_pure
|
||||
uint64_t GetPosition() const noexcept {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER zero;
|
||||
zero.QuadPart = 0;
|
||||
LARGE_INTEGER position;
|
||||
|
||||
Reference in New Issue
Block a user