summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:53:03 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:53:03 +0000
commit6d5dd02a49b18017c296c2d76bc6bb1d9f1ef6ac (patch)
tree109a3da8b5af3304fdc9d2e9f753edb611e54b95 /apt-pkg/contrib/fileutl.cc
parent10861bb5068971efe4de96e679a711ab45bb3e25 (diff)
Minor fixes for FTP support
Author: jgg Date: 1999-03-15 08:10:39 GMT Minor fixes for FTP support
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index b6a64926d..a761794ee 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.21 1999/02/16 04:18:35 jgg Exp $
+// $Id: fileutl.cc,v 1.22 1999/03/15 08:10:39 jgg Exp $
/* ######################################################################
File Utilities
@@ -164,15 +164,16 @@ void SetNonBlock(int Fd,bool Block)
// WaitFd - Wait for a FD to become readable /*{{{*/
// ---------------------------------------------------------------------
/* This waits for a FD to become readable using select. It is usefull for
- applications making use of non-blocking sockets. */
+ applications making use of non-blocking sockets. The timeout is
+ in seconds. */
bool WaitFd(int Fd,bool write,unsigned long timeout)
{
fd_set Set;
struct timeval tv;
FD_ZERO(&Set);
FD_SET(Fd,&Set);
- tv.tv_sec = timeout / 1000000;
- tv.tv_usec = timeout % 1000000;
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
if (write == true)
{
if (select(Fd+1,0,&Set,0,(timeout != 0?&tv:0)) <= 0)
@@ -278,6 +279,20 @@ bool FileFd::Seek(unsigned long To)
return true;
}
/*}}}*/
+// FileFd::Truncate - Truncate the file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool FileFd::Truncate(unsigned long To)
+{
+ if (ftruncate(iFd,To) != 0)
+ {
+ Flags |= Fail;
+ return _error->Error("Unable to truncate to %u",To);
+ }
+
+ return true;
+}
+ /*}}}*/
// FileFd::Tell - Current seek position /*{{{*/
// ---------------------------------------------------------------------
/* */