summaryrefslogtreecommitdiff
path: root/gnulib/lib/ftruncate.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnulib/lib/ftruncate.c')
m---------gnulib0
-rw-r--r--gnulib/lib/ftruncate.c43
2 files changed, 43 insertions, 0 deletions
diff --git a/gnulib b/gnulib
deleted file mode 160000
-Subproject 443bc5ffcf7429e557f4a371b0661abe98ddbc1
diff --git a/gnulib/lib/ftruncate.c b/gnulib/lib/ftruncate.c
new file mode 100644
index 0000000..ae1e858
--- /dev/null
+++ b/gnulib/lib/ftruncate.c
@@ -0,0 +1,43 @@
+/* ftruncate emulations for native Windows.
+ This file is in the public domain. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#if HAVE_CHSIZE
+
+# include <errno.h>
+# include <io.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+static inline int
+chsize_nothrow (int fd, long length)
+{
+ int result;
+
+ TRY_MSVC_INVAL
+ {
+ result = chsize (fd, length);
+ }
+ CATCH_MSVC_INVAL
+ {
+ result = -1;
+ errno = EBADF;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+# define chsize chsize_nothrow
+# endif
+
+int
+ftruncate (int fd, off_t length)
+{
+ return chsize (fd, length);
+}
+
+#endif