diff options
Diffstat (limited to 'python/tar.cc')
| -rw-r--r-- | python/tar.cc | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/python/tar.cc b/python/tar.cc index 61c9d708..e5aaee6f 100644 --- a/python/tar.cc +++ b/python/tar.cc @@ -4,7 +4,7 @@ /* ###################################################################### Tar Inteface - + ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ @@ -23,9 +23,9 @@ class ProcessTar : public pkgDirStream public: PyObject *Function; - + virtual bool DoItem(Item &Itm,int &Fd); - + ProcessTar(PyObject *Function) : Function(Function) { Py_INCREF(Function); @@ -48,55 +48,55 @@ bool ProcessTar::DoItem(Item &Itm,int &Fd) case Item::File: Type = "FILE"; break; - + case Item::HardLink: Type = "HARDLINK"; break; - + case Item::SymbolicLink: Type = "SYMLINK"; break; - + case Item::CharDevice: Type = "CHARDEV"; break; - + case Item::BlockDevice: Type = "BLKDEV"; break; - + case Item::Directory: Type = "DIR"; break; - + case Item::FIFO: Type = "FIFO"; break; } - + if (PyObject_CallFunction(Function,"sssiiiiiii",Type,Itm.Name, Itm.LinkTarget,Itm.Mode,Itm.UID,Itm.GID,Itm.Size, Itm.MTime,Itm.Major,Itm.Minor) == 0) return false; - + Fd = -1; return true; } /*}}}*/ - + // tarExtract - Examine files from a tar /*{{{*/ // --------------------------------------------------------------------- /* */ char *doc_tarExtract = "tarExtract(File,Func,Comp) -> None\n" "The tar file referenced by the file object File, Func called for each\n" -"Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n"; +"Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n"; PyObject *tarExtract(PyObject *Self,PyObject *Args) { PyObject *File; PyObject *Function; char *Comp; - + if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File, &Function,&Comp) == 0) return 0; @@ -106,19 +106,19 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args) PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable."); return 0; } - + { // Open the file and associate the tar FileFd Fd(fileno(PyFile_AsFile(File)),false); ExtractTar Tar(Fd,0xFFFFFFFF,Comp); if (_error->PendingError() == true) return HandleErrors(); - + ProcessTar Proc(Function); if (Tar.Go(Proc) == false) return HandleErrors(); - } - + } + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -138,11 +138,11 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) PyObject *Function; char *Chunk; const char *Comp = "gzip"; - + if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File, &Function,&Chunk) == 0) return 0; - + if (PyCallable_Check(Function) == 0) { PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable."); @@ -156,15 +156,15 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) debDebFile Deb(Fd); if (_error->PendingError() == true) return HandleErrors(); - - // Get the archive member and positition the file + + // Get the archive member and positition the file const ARArchive::Member *Member = Deb.GotoMember(Chunk); if (Member == 0) { _error->Error("Cannot find chunk %s",Chunk); return HandleErrors(); } - + // Extract it. if (strcmp(".bz2", &Chunk[strlen(Chunk)-4]) == 0) Comp = "bzip2"; @@ -174,8 +174,8 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) ProcessTar Proc(Function); if (Tar.Go(Proc) == false) return HandleErrors(); - } - + } + Py_INCREF(Py_None); return HandleErrors(Py_None); } |
