]>
git.saurik.com Git - apt.git/blob - test/testextract.cc
1 #define APT_COMPATIBILITY 1
2 #include <apt-pkg/dpkgdb.h>
3 #include <apt-pkg/debfile.h>
4 #include <apt-pkg/error.h>
5 #include <apt-pkg/configuration.h>
6 #include <apt-pkg/progress.h>
7 #include <apt-pkg/extract.h>
8 #include <apt-pkg/init.h>
9 #include <apt-pkg/strutl.h>
14 bool Go(int argc
,char *argv
[])
21 if (Db
.ReadyPkgCache(Prog
) == false)
25 if (Db
.ReadyFileList(Prog
) == false)
29 for (int I
= 1; I
< argc
; I
++)
32 for (unsigned J
= 0; argv
[I
][J
] != 0; J
++)
34 if (argv
[I
][J
] != ',')
36 Fake
= argv
[I
] + J
+ 1;
40 FileFd
F(argv
[I
],FileFd::ReadOnly
);
43 if (_error
->PendingError() == true)
46 if (Deb
.ExtractControl(Db
) == false)
48 cout
<< argv
[I
] << endl
;
50 pkgCache::VerIterator Ver
= Deb
.MergeControl(Db
);
51 if (Ver
.end() == true)
54 cout
<< Ver
.ParentPkg().Name() << ' ' << Ver
.VerStr() << endl
;
56 pkgExtract
Extract(Db
.GetFLCache(),Ver
);
61 memset(&Itm
,0,sizeof(Itm
));
62 FILE *F
= fopen(Fake
,"r");
66 fgets(Line
,sizeof(Line
),F
);
67 Itm
.Name
= _strstrip(Line
);
68 Itm
.Type
= pkgDirStream::Item::File
;
69 if (Line
[strlen(Line
)-1] == '/')
70 Itm
.Type
= pkgDirStream::Item::Directory
;
73 if (Extract
.DoItem(Itm
,Fd
) == false)
78 if (Deb
.ExtractArchive(Extract
) == false)
84 int main(int argc
,char *argv
[])
86 pkgInitialize(*_config
);
87 _config
->Set("Dir::State::status","/tmp/testing/status");
91 if (_error
->PendingError() == true)