summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:57:31 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:57:31 +0000
commitf604cf55e27db1121895a84a525f305a78a3dad9 (patch)
treed049f8efc18eceed369f7df04792aa511c804480 /apt-pkg/contrib
parent5d622d510f558981275d6004ec015013dea9cdbf (diff)
Tag file can read from unseekable objects
Author: jgg Date: 2001-04-22 05:42:52 GMT Tag file can read from unseekable objects
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc11
-rw-r--r--apt-pkg/contrib/fileutl.h11
2 files changed, 17 insertions, 5 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index db878064d..97dcb82b8 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.37 2001/03/03 22:45:59 tausq Exp $
+// $Id: fileutl.cc,v 1.38 2001/04/22 05:42:52 jgg Exp $
/* ######################################################################
File Utilities
@@ -431,10 +431,13 @@ FileFd::~FileFd()
// ---------------------------------------------------------------------
/* We are carefull to handle interruption by a signal while reading
gracefully. */
-bool FileFd::Read(void *To,unsigned long Size,bool AllowEof)
+bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual)
{
int Res;
errno = 0;
+ if (Actual != 0)
+ *Actual = 0;
+
do
{
Res = read(iFd,To,Size);
@@ -448,6 +451,8 @@ bool FileFd::Read(void *To,unsigned long Size,bool AllowEof)
To = (char *)To + Res;
Size -= Res;
+ if (Actual != 0)
+ *Actual += Res;
}
while (Res > 0 && Size > 0);
@@ -455,7 +460,7 @@ bool FileFd::Read(void *To,unsigned long Size,bool AllowEof)
return true;
// Eof handling
- if (AllowEof == true)
+ if (Actual != 0)
{
Flags |= HitEof;
return true;
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 74e0d542f..8d5f03b05 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.h,v 1.24 2001/03/03 22:36:20 tausq Exp $
+// $Id: fileutl.h,v 1.25 2001/04/22 05:42:53 jgg Exp $
/* ######################################################################
File Utilities
@@ -40,7 +40,14 @@ class FileFd
public:
enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp};
- bool Read(void *To,unsigned long Size,bool AllowEof = false);
+ inline bool Read(void *To,unsigned long Size,bool AllowEof)
+ {
+ unsigned long Jnk;
+ if (AllowEof)
+ return Read(To,Size,&Jnk);
+ return Read(To,Size);
+ }
+ bool Read(void *To,unsigned long Size,unsigned long *Actual = 0);
bool Write(const void *From,unsigned long Size);
bool Seek(unsigned long To);
bool Skip(unsigned long To);