]> git.saurik.com Git - apt.git/blame - apt-private/private-cachefile.h
Merge remote-tracking branch 'mvo/bugfix/update-progress-reporting' into debian/exper...
[apt.git] / apt-private / private-cachefile.h
CommitLineData
b9179170
MV
1#ifndef APT_PRIVATE_CACHEFILE_H
2#define APT_PRIVATE_CACHEFILE_H
3
4#include <apt-pkg/cachefile.h>
5#include <apt-pkg/progress.h>
453b82a3
DK
6#include <apt-pkg/configuration.h>
7#include <apt-pkg/pkgcache.h>
63ff4208 8#include <apt-pkg/macros.h>
aaf677da
MV
9#include <apt-pkg/sourcelist.h>
10#include <apti18n.h>
b9179170 11
aaf677da
MV
12// FIXME: we need to find a way to export this
13class APT_PUBLIC SourceList : public pkgSourceList
14{
15
16 public:
17 // Add custom metaIndex (e.g. local files)
18 void AddMetaIndex(metaIndex *mi) {
19 SrcList.push_back(mi);
20 }
21
22};
b9179170
MV
23
24// class CacheFile - Cover class for some dependency cache functions /*{{{*/
25// ---------------------------------------------------------------------
26/* */
63ff4208 27class APT_PUBLIC CacheFile : public pkgCacheFile
b9179170
MV
28{
29 static pkgCache *SortCache;
63ff4208
DK
30 APT_HIDDEN static int NameComp(const void *a,const void *b) APT_PURE;
31
b9179170
MV
32 public:
33 pkgCache::Package **List;
34
35 void Sort();
36 bool CheckDeps(bool AllowBroken = false);
37 bool BuildCaches(bool WithLock = true)
38 {
39 OpTextProgress Prog(*_config);
40 if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false)
41 return false;
42 return true;
43 }
aaf677da
MV
44 // FIXME: this can go once the "libapt-pkg" pkgSourceList has a way
45 // to add custom metaIndexes (or custom local files or so)
46 bool BuildSourceList(OpProgress */*Progress*/ = NULL) {
47 if (SrcList != NULL)
48 return true;
49 SrcList = new SourceList();
50 if (SrcList->ReadMainList() == false)
51 return _error->Error(_("The list of sources could not be read."));
52 return true;
53 }
b9179170
MV
54 bool Open(bool WithLock = true)
55 {
56 OpTextProgress Prog(*_config);
57 if (pkgCacheFile::Open(&Prog,WithLock) == false)
58 return false;
59 Sort();
60
61 return true;
62 };
63 bool OpenForInstall()
64 {
65 if (_config->FindB("APT::Get::Print-URIs") == true)
66 return Open(false);
67 else
68 return Open(true);
69 }
70 CacheFile() : List(0) {};
71 ~CacheFile() {
72 delete[] List;
73 }
74};
75 /*}}}*/
76
77#endif