mirror of https://github.com/BOINC/boinc.git
windows file truncate
svn path=/trunk/boinc/; revision=9264
This commit is contained in:
parent
ba9ba5ff01
commit
60ac02c663
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue