aboutsummaryrefslogtreecommitdiff
path: root/src/xz/file_io.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-09-05 22:42:10 +0300
committerLasse Collin <lasse.collin@tukaani.org>2023-09-22 20:00:38 +0300
commit79334e7f20f2bf9e0de095835b48868f1238f584 (patch)
treefb1182bb184b9cf9baa0701c54438e540e87fa28 /src/xz/file_io.c
parentMSVC: xz: Use GetTickCount64() to implement mytime_now(). (diff)
downloadxz-79334e7f20f2bf9e0de095835b48868f1238f584.tar.xz
MSVC: xz: Make file_io.c and file_io.h compatible with MSVC.
Thanks to Kelvin Lee for the original patches and testing the modifications I made.
Diffstat (limited to 'src/xz/file_io.c')
-rw-r--r--src/xz/file_io.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/xz/file_io.c b/src/xz/file_io.c
index 767c819a..f0d895bc 100644
--- a/src/xz/file_io.c
+++ b/src/xz/file_io.c
@@ -39,6 +39,32 @@ static bool warn_fchown;
#include "tuklib_open_stdxxx.h"
+#ifdef _MSC_VER
+# ifdef _WIN64
+ typedef __int64 ssize_t;
+# else
+ typedef int ssize_t;
+# endif
+
+ typedef int mode_t;
+# define S_IRUSR _S_IREAD
+# define S_IWUSR _S_IWRITE
+
+# define setmode _setmode
+# define open _open
+# define close _close
+# define lseek _lseeki64
+# define unlink _unlink
+
+ // The casts are to silence warnings.
+ // The sizes are known to be small enough.
+# define read(fd, buf, size) _read(fd, buf, (unsigned int)(size))
+# define write(fd, buf, size) _write(fd, buf, (unsigned int)(size))
+
+# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
+#endif
+
#ifndef O_BINARY
# define O_BINARY 0
#endif