]>
git.saurik.com Git - apt.git/blob - apt-pkg/cachefile.cc
4bc93fd7c326ca5a601083f41fa56116970e9923
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: cachefile.cc,v 1.6 2001/03/13 06:51:46 jgg Exp $
4 /* ######################################################################
6 CacheFile - Simple wrapper class for opening, generating and whatnot
8 This class implements a simple 2 line mechanism to open various sorts
9 of caches. It can operate as root, as not root, show progress and so on,
10 it transparently handles everything necessary.
12 ##################################################################### */
14 // Include Files /*{{{*/
16 #pragma implementation "apt-pkg/cachefile.h"
19 #include <apt-pkg/cachefile.h>
20 #include <apt-pkg/error.h>
21 #include <apt-pkg/sourcelist.h>
22 #include <apt-pkg/pkgcachegen.h>
23 #include <apt-pkg/configuration.h>
24 #include <apt-pkg/policy.h>
25 #include <apt-pkg/pkgsystem.h>
30 // CacheFile::CacheFile - Constructor /*{{{*/
31 // ---------------------------------------------------------------------
33 pkgCacheFile::pkgCacheFile() : Map(0), Cache(0), DCache(0), Policy(0)
37 // CacheFile::~CacheFile - Destructor /*{{{*/
38 // ---------------------------------------------------------------------
40 pkgCacheFile::~pkgCacheFile()
46 _system
->UnLock(true);
49 // CacheFile::Open - Open the cache files, creating if necessary /*{{{*/
50 // ---------------------------------------------------------------------
52 bool pkgCacheFile::Open(OpProgress
&Progress
,bool WithLock
)
55 if (_system
->Lock() == false)
58 if (_error
->PendingError() == true)
61 // Read the source list
63 if (List
.ReadMainList() == false)
64 return _error
->Error(_("The list of sources could not be read."));
67 bool Res
= pkgMakeStatusCache(List
,Progress
,&Map
,!WithLock
);
70 return _error
->Error(_("The package lists or status file could not be parsed or opened."));
72 /* This sux, remove it someday */
73 if (_error
->empty() == false)
74 _error
->Warning(_("You may want to run apt-get update to correct these problems"));
76 Cache
= new pkgCache(Map
);
77 if (_error
->PendingError() == true)
81 Policy
= new pkgPolicy(Cache
);
82 if (_error
->PendingError() == true)
84 if (ReadPinFile(*Policy
) == false)
87 // Create the dependency cache
88 DCache
= new pkgDepCache(Cache
,Policy
);
89 if (_error
->PendingError() == true)
92 DCache
->Init(&Progress
);
94 if (_error
->PendingError() == true)
101 // CacheFile::Close - close the cache files /*{{{*/
102 // ---------------------------------------------------------------------
104 void pkgCacheFile::Close()
110 _system
->UnLock(true);