Changeset: 528f6adfbf1d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=528f6adfbf1d
Modified Files:
        NT/monetdb_config.h.in
        clients/Tests/exports.stable.out
        gdk/gdk_posix.c
        gdk/gdk_posix.h
Branch: default
Log Message:

On Windows we can use _chsize_s for ftruncate.


diffs (74 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -148,7 +148,8 @@
 #define HAVE_FTIME 1
 
 /* Define to 1 if you have the `ftruncate' function. */
-/* #undef HAVE_FTRUNCATE */
+#define HAVE_FTRUNCATE 1
+#define ftruncate(fd, sz)      (_chsize_s((fd), (__int64) (sz)) == 0 ? 0 : -1)
 
 /* Does your compiler support function attributes (__attribute__)? */
 /* #undef HAVE_FUNCTION_ATTRIBUTES */
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -421,7 +421,6 @@ int escapedStrlen(const char *src);
 int fltFromStr(const char *src, int *len, flt **dst);
 int fltToStr(str *dst, int *len, const flt *src);
 const flt flt_nil;
-int ftruncate(int fd, off_t size);
 char *get_bin_path(void);
 int gettimeofday(struct timeval *tv, int *ignore_zone);
 int gprof_pthread_create(pthread_t *__restrict, __const pthread_attr_t 
*__restrict, void *( *fcn)(void *), void *__restrict);
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -854,32 +854,6 @@ MT_path_absolute(const char *pathname)
 }
 
 
-#ifndef HAVE_FTRUNCATE
-int
-ftruncate(int fd, off_t size)
-{
-       HANDLE hfile;
-       unsigned int curpos;
-
-       if (fd < 0)
-               return -1;
-
-       hfile = (HANDLE) _get_osfhandle(fd);
-       curpos = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
-       if (curpos == 0xFFFFFFFF ||
-           SetFilePointer(hfile, (LONG) size, NULL, FILE_BEGIN) == 0xFFFFFFFF 
||
-           !SetEndOfFile(hfile)) {
-               int error = GetLastError();
-
-               if (error && error != ERROR_INVALID_HANDLE)
-                       SetLastError(ERROR_OPEN_FAILED);        /* enforce EIO 
*/
-               return -1;
-       }
-
-       return 0;
-}
-#endif
-
 #ifndef HAVE_GETTIMEOFDAY
 static int nodays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
 
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -252,10 +252,6 @@ gdk_export int win_mkdir(const char *, c
 #define link           win_link
 #endif
 
-#ifndef HAVE_FTRUNCATE
-gdk_export int ftruncate(int fd, off_t size);
-#endif
-
 #endif
 
 #define _errno         win_errno
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to