summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-11-21 10:33:10 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-11-21 10:33:10 +0000
commita9d234dfe2ab0358d3e61a53645e4ee1d83e53cb (patch)
tree9b66689add80af09a4b328a4b7891fb7841b82b8 /python
parent2fa652df49918cbfd8def4868b327bab3b30feb9 (diff)
downloadpython-apt-a9d234dfe2ab0358d3e61a53645e4ee1d83e53cb.tar.gz
* apt_inst.debExtractArchive() added
Diffstat (limited to 'python')
-rw-r--r--python/apt_instmodule.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc
index 96bd029b..d672a40a 100644
--- a/python/apt_instmodule.cc
+++ b/python/apt_instmodule.cc
@@ -66,6 +66,43 @@ static PyObject *debExtractControl(PyObject *Self,PyObject *Args)
}
/*}}}*/
+// debExtractArchive - Exctract the archive /*{{{*/
+// ---------------------------------------------------------------------
+static char *doc_debExtractArchive =
+"debExtractArchve(File,rootdir) -> Bool\n"
+"Extracts the Archive into the given root dir";
+static PyObject *debExtractArchive(PyObject *Self,PyObject *Args)
+{
+ char *Rootdir = NULL;
+ PyObject *File;
+ if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0)
+ return 0;
+
+ // Subscope makes sure any clean up errors are properly handled.
+ bool res = false;
+ {
+ if(Rootdir != NULL)
+ {
+ chdir(Rootdir);
+ }
+
+ // Open the file and associate the .deb
+ FileFd Fd(fileno(PyFile_AsFile(File)),false);
+ debDebFile Deb(Fd);
+ if (_error->PendingError() == true)
+ return HandleErrors();
+
+ // extracts relative to the current dir
+ pkgDirStream Extract;
+ res = Deb.ExtractArchive(Extract);
+
+ if (res == false)
+ return HandleErrors();
+ }
+ return HandleErrors(Py_BuildValue("b",res));
+}
+ /*}}}*/
+
// initapt_inst - Core Module Initialization /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -73,6 +110,7 @@ static PyMethodDef methods[] =
{
// Stuff
{"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl},
+ {"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive},
{"tarExtract",tarExtract,METH_VARARGS,doc_tarExtract},
{"debExtract",debExtract,METH_VARARGS,doc_debExtract},