diff options
author | Julian Andres Klode <jak@debian.org> | 2010-07-23 16:13:15 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2010-07-23 16:13:15 +0200 |
commit | 144c096976b2ce05fe64e5761c0df5854f6c0c09 (patch) | |
tree | df62a8967934abaad52cee1a0f10415f4caefede | |
parent | 6bf8f0d198f00dcbb46dba97840681fa2227177a (diff) |
* apt-pkg/contrib/fileutl.cc:
- Add FileFd::OpenDescriptor() (needed for python-apt's #383617).
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 18 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 4 | ||||
-rw-r--r-- | debian/changelog | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 49b2f3828..2a3b8a87d 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -700,6 +700,24 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms) SetCloseExec(iFd,true); return true; } + +bool FileFd::OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose) +{ + Close(); + Flags = (AutoClose) ? FileFd::AutoClose : 0; + iFd = Fd; + if (Mode == ReadOnlyGzip) { + gz = gzdopen (iFd, "r"); + if (gz == NULL) { + if (AutoClose) + close (iFd); + return _error->Errno("gzdopen",_("Could not open file descriptor %d"), + Fd); + } + } + this->FileName = ""; + return true; +} /*}}}*/ // FileFd::~File - Closes the file /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 0f70ab722..62705478d 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -28,6 +28,9 @@ #include <zlib.h> +/* Define this for python-apt */ +#define APT_HAS_GZIP 1 + using std::string; class FileFd @@ -60,6 +63,7 @@ class FileFd unsigned long Tell(); unsigned long Size(); bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666); + bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false); bool Close(); bool Sync(); diff --git a/debian/changelog b/debian/changelog index 311833192..06454cd5a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ apt (0.7.26~exp11) experimental; urgency=low * apt-pkg/deb/dpkgpm.cc: - Write architecture information to history file. - Add to history whether a change was automatic or not. + * apt-pkg/contrib/fileutl.cc: + - Add FileFd::OpenDescriptor() (needed for python-apt's #383617). -- Julian Andres Klode <jak@debian.org> Wed, 21 Jul 2010 17:09:11 +0200 |