summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/mmap.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-12-11 19:46:59 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-12-11 19:46:59 +0100
commit032bd56ff86166fd4b6a8f69bd9d5d1bc57b886e (patch)
treea7265cb15015b80554eedfa8e3a8f0c8fafff687 /apt-pkg/contrib/mmap.cc
parenteed564b853a0e5778080c5c3012517a814041d5a (diff)
- add a ReadLine method
- drop the explicit export of gz-compression handling
Diffstat (limited to 'apt-pkg/contrib/mmap.cc')
-rw-r--r--apt-pkg/contrib/mmap.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index f76169a92..1fb84b0af 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -77,7 +77,18 @@ bool MMap::Map(FileFd &Fd)
if (iSize == 0)
return _error->Error(_("Can't mmap an empty file"));
-
+
+ // We can't mmap compressed fd's directly, so we need to read it completely
+ if (Fd.IsCompressed() == true)
+ {
+ if ((Flags & ReadOnly) != ReadOnly)
+ return _error->Error("Compressed file %s can only be mapped readonly", Fd.Name().c_str());
+ Base = new unsigned char[iSize];
+ if (Fd.Seek(0L) == false || Fd.Read(Base, iSize) == false)
+ return false;
+ return true;
+ }
+
// Map it.
Base = mmap(0,iSize,Prot,Map,Fd.Fd(),0);
if (Base == (void *)-1)