- Add FileFd::OpenDescriptor() (needed for python-apt's #383617).
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 /*{{{*/
// ---------------------------------------------------------------------
#include <zlib.h>
+/* Define this for python-apt */
+#define APT_HAS_GZIP 1
+
using std::string;
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();
* 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