]>
git.saurik.com Git - apt.git/blob - apt-pkg/cachefile.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: cachefile.cc,v 1.4 1999/06/24 04:06:30 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>
26 // CacheFile::CacheFile - Constructor /*{{{*/
27 // ---------------------------------------------------------------------
29 pkgCacheFile::pkgCacheFile() : Map(0), Cache(0), Lock(0)
33 // CacheFile::~CacheFile - Destructor /*{{{*/
34 // ---------------------------------------------------------------------
36 pkgCacheFile::~pkgCacheFile()
43 // CacheFile::Open - Open the cache files, creating if necessary /*{{{*/
44 // ---------------------------------------------------------------------
46 bool pkgCacheFile::Open(OpProgress
&Progress
,bool WithLock
)
49 Lock
= new pkgDpkgLock
;
51 if (_error
->PendingError() == true)
54 // Read the source list
56 if (List
.ReadMainList() == false)
57 return _error
->Error("The list of sources could not be read.");
59 /* Build all of the caches, using the cache files if we are locking
63 pkgMakeStatusCache(List
,Progress
);
65 if (_error
->PendingError() == true)
66 return _error
->Error("The package lists or status file could not be parsed or opened.");
67 if (_error
->empty() == false)
68 _error
->Warning("You may want to run apt-get update to correct these missing files");
70 // Open the cache file
71 FileFd
File(_config
->FindFile("Dir::Cache::pkgcache"),FileFd::ReadOnly
);
72 if (_error
->PendingError() == true)
75 Map
= new MMap(File
,MMap::Public
| MMap::ReadOnly
);
76 if (_error
->PendingError() == true)
81 Map
= pkgMakeStatusCacheMem(List
,Progress
);
87 // Create the dependency cache
88 Cache
= new pkgDepCache(*Map
,Progress
);
90 if (_error
->PendingError() == true)