diff options
author | Max Kellermann <max@duempel.org> | 2015-03-05 08:03:38 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-03-05 08:58:04 +0100 |
commit | 6887d5d347ff6349ae117cb8f16ead97c27cc427 (patch) | |
tree | 03e70d6aa40dddf73305e027c44491da00c0088b | |
parent | 39c96694454822ade1d3a686f6e29bd52fa5a4d1 (diff) | |
download | mpd-6887d5d347ff6349ae117cb8f16ead97c27cc427.tar.gz mpd-6887d5d347ff6349ae117cb8f16ead97c27cc427.tar.xz mpd-6887d5d347ff6349ae117cb8f16ead97c27cc427.zip |
fs/Traits: use TCHAR on Windows
Diffstat (limited to '')
-rw-r--r-- | src/fs/FileSystem.hxx | 16 | ||||
-rw-r--r-- | src/fs/Traits.hxx | 5 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/fs/FileSystem.hxx b/src/fs/FileSystem.hxx index ac4e0998d..a6240bf0e 100644 --- a/src/fs/FileSystem.hxx +++ b/src/fs/FileSystem.hxx @@ -55,7 +55,11 @@ namespace FOpenMode { static inline FILE * FOpen(Path file, PathTraitsFS::const_pointer mode) { +#ifdef WIN32 + return _tfopen(file.c_str(), mode); +#else return fopen(file.c_str(), mode); +#endif } /** @@ -64,7 +68,11 @@ FOpen(Path file, PathTraitsFS::const_pointer mode) static inline int 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); +#endif } /** @@ -73,7 +81,11 @@ OpenFile(Path file, int flags, int mode) static inline bool 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; +#endif } #ifndef WIN32 @@ -98,7 +110,11 @@ StatFile(Path file, struct stat &buf, bool follow_symlinks = true) static inline bool RemoveFile(Path file) { +#ifdef WIN32 + return _tunlink(file.c_str()) == 0; +#else return unlink(file.c_str()) == 0; +#endif } /** diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index b557dd752..cdd9b531d 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -26,13 +26,18 @@ #ifdef WIN32 #include "util/CharUtil.hxx" +#include <tchar.h> #endif #include <string> #include <assert.h> +#ifdef WIN32 +#define PATH_LITERAL(s) _T(s) +#else #define PATH_LITERAL(s) (s) +#endif /** * This class describes the nature of a native filesystem path. |