diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-02-02 22:42:06 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-02-02 22:42:06 +0000 |
commit | 3fd68a6a044e674d434353d5631aba2743e0bf89 (patch) | |
tree | 9f507acf3ea9c2c357cf233519a2d178dbf3b929 /winsup/cygwin/syscalls.cc | |
parent | 7823d9bb14798143e9791303186c7129336356dd (diff) | |
download | cygnal-3fd68a6a044e674d434353d5631aba2743e0bf89.tar.gz cygnal-3fd68a6a044e674d434353d5631aba2743e0bf89.tar.bz2 cygnal-3fd68a6a044e674d434353d5631aba2743e0bf89.zip |
* fhandler.h (fhandler_base::ftruncate): Define new virtual method.
(fhandler_disk_file::ftruncate): Ditto.
* fhandler.cc (fhandler_base::ftruncate): New method.
* fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto.
* syscalls.cc (ftruncate64): Move functionality into fhandlers.
Call fhandler method from here.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 8548f5e4a..d4f497246 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1737,37 +1737,12 @@ setmode (int fd, int mode) extern "C" int ftruncate64 (int fd, _off64_t length) { - int res = -1, res_bug = 0; - - if (length < 0) - set_errno (EINVAL); + int res = -1; + cygheap_fdget cfd (fd); + if (cfd >= 0) + res = cfd->ftruncate (length); else - { - cygheap_fdget cfd (fd); - if (cfd >= 0) - { - HANDLE h = cygheap->fdtab[fd]->get_handle (); - - if (cfd->get_handle ()) - { - /* remember curr file pointer location */ - _off64_t prev_loc = cfd->lseek (0, SEEK_CUR); - - cfd->lseek (length, SEEK_SET); - /* Fill the space with 0, if needed */ - if (wincap.has_lseek_bug ()) - res_bug = cfd->write (&res, 0); - if (!SetEndOfFile (h)) - __seterrno (); - else - res = res_bug; - - /* restore original file pointer location */ - cfd->lseek (prev_loc, SEEK_SET); - } - } - } - + set_errno (EBADF); syscall_printf ("%d = ftruncate (%d, %D)", res, fd, length); return res; } |