summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/mmap.cc
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:56:32 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:56:32 +0000
commitb2e465d6d32d2dc884f58b94acb7e35f671a87fe (patch)
tree5928383b9bde7b0ba9812e6526ad746466e558f7 /apt-pkg/contrib/mmap.cc
parent00b47c98ca4a4349686a082eba6d77decbb03a4d (diff)
Join with aliencode
Author: jgg Date: 2001-02-20 07:03:16 GMT Join with aliencode
Diffstat (limited to 'apt-pkg/contrib/mmap.cc')
-rw-r--r--apt-pkg/contrib/mmap.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 230e133a5..cfe476763 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: mmap.cc,v 1.20 1999/10/02 04:14:54 jgg Exp $
+// $Id: mmap.cc,v 1.21 2001/02/20 07:03:17 jgg Exp $
/* ######################################################################
MMap Class - Provides 'real' mmap or a faked mmap using read().
@@ -29,6 +29,8 @@
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
+#include <apti18n.h>
+
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -77,12 +79,12 @@ bool MMap::Map(FileFd &Fd)
Map = MAP_PRIVATE;
if (iSize == 0)
- return _error->Error("Can't mmap an empty file");
+ return _error->Error(_("Can't mmap an empty file"));
// Map it.
Base = mmap(0,iSize,Prot,Map,Fd.Fd(),0);
if (Base == (void *)-1)
- return _error->Errno("mmap","Couldn't make mmap of %u bytes",iSize);
+ return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"),iSize);
return true;
}
@@ -102,6 +104,7 @@ bool MMap::Close(bool DoSync)
_error->Warning("Unable to munmap");
iSize = 0;
+ Base = 0;
return true;
}
/*}}}*/
@@ -150,9 +153,15 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace)
return;
unsigned long EndOfFile = Fd->Size();
- Fd->Seek(WorkSpace);
- char C = 0;
- Fd->Write(&C,sizeof(C));
+ if (EndOfFile > WorkSpace)
+ WorkSpace = EndOfFile;
+ else
+ {
+ Fd->Seek(WorkSpace);
+ char C = 0;
+ Fd->Write(&C,sizeof(C));
+ }
+
Map(F);
iSize = EndOfFile;
}
@@ -182,11 +191,9 @@ DynamicMMap::~DynamicMMap()
}
unsigned long EndOfFile = iSize;
- Sync();
iSize = WorkSpace;
Close(false);
ftruncate(Fd->Fd(),EndOfFile);
- Fd->Close();
}
/*}}}*/
// DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space /*{{{*/