diff --git a/checkin_notes b/checkin_notes index 2f1d79aa6f..0fa015f44c 100755 --- a/checkin_notes +++ b/checkin_notes @@ -588,3 +588,9 @@ David 18 Jan 2006 error_numbers.h filesys.C,h util.C + +David 18 Jan 2006 + - implement boinc_truncate() for Windows + + lib/ + filesys.C diff --git a/lib/filesys.C b/lib/filesys.C index ec0025a046..e30a062658 100755 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -276,7 +276,20 @@ int file_size(const char* path, double& size) { } int boinc_truncate(const char* path, double size) { - int retval = truncate(path, (off_t)size); + int retval; +#ifdef _WIN32 + // the usual Windows nightmare. + // There's another function, SetEndOfFile(), + // that supposedly works with files over 2GB, + // but it uses HANDLES + // + int fd = _open(path, _O_RDWR, 0); + if (fd == -1) return ERR_TRUNCATE; + retval = _chsize(fd, (long)size); + _close(fd); +#else + retval = truncate(path, (off_t)size); +#endif if (retval) return ERR_TRUNCATE; return 0; }