]>
git.saurik.com Git - apt.git/blob - test/testextract.cc
1 #include <apt-pkg/dpkgdb.h>
2 #include <apt-pkg/debfile.h>
3 #include <apt-pkg/error.h>
4 #include <apt-pkg/configuration.h>
5 #include <apt-pkg/progress.h>
6 #include <apt-pkg/extract.h>
7 #include <apt-pkg/init.h>
8 #include <apt-pkg/strutl.h>
15 bool Go(int argc
,char *argv
[])
22 if (Db
.ReadyPkgCache(Prog
) == false)
26 if (Db
.ReadyFileList(Prog
) == false)
30 for (int I
= 1; I
< argc
; I
++)
33 for (unsigned J
= 0; argv
[I
][J
] != 0; J
++)
35 if (argv
[I
][J
] != ',')
37 Fake
= argv
[I
] + J
+ 1;
41 FileFd
F(argv
[I
],FileFd::ReadOnly
);
44 if (_error
->PendingError() == true)
47 if (Deb
.ExtractControl(Db
) == false)
49 cout
<< argv
[I
] << endl
;
51 pkgCache::VerIterator Ver
= Deb
.MergeControl(Db
);
52 if (Ver
.end() == true)
55 cout
<< Ver
.ParentPkg().Name() << ' ' << Ver
.VerStr() << endl
;
57 pkgExtract
Extract(Db
.GetFLCache(),Ver
);
62 memset(&Itm
,0,sizeof(Itm
));
63 FILE *F
= fopen(Fake
,"r");
67 fgets(Line
,sizeof(Line
),F
);
68 Itm
.Name
= _strstrip(Line
);
69 Itm
.Type
= pkgDirStream::Item::File
;
70 if (Line
[strlen(Line
)-1] == '/')
71 Itm
.Type
= pkgDirStream::Item::Directory
;
74 if (Extract
.DoItem(Itm
,Fd
) == false)
79 if (Deb
.ExtractArchive(Extract
) == false)
85 int main(int argc
,char *argv
[])
87 pkgInitConfig(*_config
);
88 pkgInitSystem(*_config
,_system
);
89 _config
->Set("Dir::State::status","/tmp/testing/status");
93 if (_error
->PendingError() == true)