summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-11-15 10:28:27 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-11-15 10:28:27 +0100
commit58a642755c63cde3cf377d3719d66add27b13d65 (patch)
tree92719b94ccca55b5e128f28e9499e1ec331a5440 /apt-pkg/contrib/fileutl.cc
parentfd8bb61d2945d2e2f19f0e0a753129235717a9f3 (diff)
parent3cf1e4b50a9bb439c4f54a631cfebbb6c4d1ea7d (diff)
merged from debian
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index cbf1d64a9..f4ab066d7 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -910,18 +910,24 @@ unsigned long FileFd::Tell()
return Res;
}
/*}}}*/
-// FileFd::Size - Return the size of the file /*{{{*/
+// FileFd::FileSize - Return the size of the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned long FileFd::Size()
+unsigned long FileFd::FileSize()
{
struct stat Buf;
- unsigned long size;
- off_t orig_pos;
if (fstat(iFd,&Buf) != 0)
return _error->Errno("fstat","Unable to determine the file size");
- size = Buf.st_size;
+ return Buf.st_size;
+}
+ /*}}}*/
+// FileFd::Size - Return the size of the content in the file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+unsigned long FileFd::Size()
+{
+ unsigned long size = FileSize();
// only check gzsize if we are actually a gzip file, just checking for
// "gz" is not sufficient as uncompressed files will be opened with
@@ -931,7 +937,7 @@ unsigned long FileFd::Size()
/* unfortunately zlib.h doesn't provide a gzsize(), so we have to do
* this ourselves; the original (uncompressed) file size is the last 32
* bits of the file */
- orig_pos = lseek(iFd, 0, SEEK_CUR);
+ off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
if (lseek(iFd, -4, SEEK_END) < 0)
return _error->Errno("lseek","Unable to seek to end of gzipped file");
if (read(iFd, &size, 4) != 4)