Commit 6887d5d3 authored by Max Kellermann's avatar Max Kellermann

fs/Traits: use TCHAR on Windows

parent 39c96694
...@@ -55,7 +55,11 @@ namespace FOpenMode { ...@@ -55,7 +55,11 @@ namespace FOpenMode {
static inline FILE * static inline FILE *
FOpen(Path file, PathTraitsFS::const_pointer mode) FOpen(Path file, PathTraitsFS::const_pointer mode)
{ {
#ifdef WIN32
return _tfopen(file.c_str(), mode);
#else
return fopen(file.c_str(), mode); return fopen(file.c_str(), mode);
#endif
} }
/** /**
...@@ -64,7 +68,11 @@ FOpen(Path file, PathTraitsFS::const_pointer mode) ...@@ -64,7 +68,11 @@ FOpen(Path file, PathTraitsFS::const_pointer mode)
static inline int static inline int
OpenFile(Path file, int flags, int mode) OpenFile(Path file, int flags, int mode)
{ {
#ifdef WIN32
return _topen(file.c_str(), flags, mode);
#else
return open_cloexec(file.c_str(), flags, mode); return open_cloexec(file.c_str(), flags, mode);
#endif
} }
/** /**
...@@ -73,7 +81,11 @@ OpenFile(Path file, int flags, int mode) ...@@ -73,7 +81,11 @@ OpenFile(Path file, int flags, int mode)
static inline bool static inline bool
RenameFile(Path oldpath, Path newpath) RenameFile(Path oldpath, Path newpath)
{ {
#ifdef WIN32
return _trename(oldpath.c_str(), newpath.c_str()) == 0;
#else
return rename(oldpath.c_str(), newpath.c_str()) == 0; return rename(oldpath.c_str(), newpath.c_str()) == 0;
#endif
} }
#ifndef WIN32 #ifndef WIN32
...@@ -98,7 +110,11 @@ StatFile(Path file, struct stat &buf, bool follow_symlinks = true) ...@@ -98,7 +110,11 @@ StatFile(Path file, struct stat &buf, bool follow_symlinks = true)
static inline bool static inline bool
RemoveFile(Path file) RemoveFile(Path file)
{ {
#ifdef WIN32
return _tunlink(file.c_str()) == 0;
#else
return unlink(file.c_str()) == 0; return unlink(file.c_str()) == 0;
#endif
} }
/** /**
......
...@@ -26,13 +26,18 @@ ...@@ -26,13 +26,18 @@
#ifdef WIN32 #ifdef WIN32
#include "util/CharUtil.hxx" #include "util/CharUtil.hxx"
#include <tchar.h>
#endif #endif
#include <string> #include <string>
#include <assert.h> #include <assert.h>
#ifdef WIN32
#define PATH_LITERAL(s) _T(s)
#else
#define PATH_LITERAL(s) (s) #define PATH_LITERAL(s) (s)
#endif
/** /**
* This class describes the nature of a native filesystem path. * This class describes the nature of a native filesystem path.
......
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