The MSVC Posix implementation doesn't contain ftruncate, so add our own
which can handle large files (64bit offsets).
Signed-off-by: Marius Storm-Olsen <redacted>
---
compat/msvc.c | 8 ++++++++
compat/msvc.h | 2 ++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/compat/msvc.c b/compat/msvc.c
index ac04a4c..b96b045 100644
--- a/compat/msvc.c
+++ b/compat/msvc.c
@@ -32,4 +32,12 @@ int closedir(DIR *dir)
return 0;
}
+int ftruncate(int fd, __int64 length)
+{
+ HANDLE fh = (HANDLE)_get_osfhandle(fd);
+ if (!fh || _lseeki64(fd, length, SEEK_SET))
+ return -1;
+ return SetEndOfFile(fh) ? 0 : -1;
+}
+
#include "mingw.c"diff --git a/compat/msvc.h b/compat/msvc.h
index a62507f..d9fc04b 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -46,4 +46,6 @@ struct _stati64 {
time_t st_mtime;
time_t st_ctime;
};
+
+int ftruncate(int fd, __int64 length);
#endif--
1.6.2.1.418.g33d56.dirty