diff options
Diffstat (limited to '')
| -rw-r--r-- | src/cache.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/cache.cpp b/src/cache.cpp index d6269e3..8d6a91e 100644 --- a/src/cache.cpp +++ b/src/cache.cpp | |||
| @@ -5,60 +5,60 @@ | |||
| 5 | using namespace Bu; | 5 | using namespace Bu; |
| 6 | 6 | ||
| 7 | Cache::Cache() : | 7 | Cache::Cache() : |
| 8 | bCacheChanged( false ), | 8 | bCacheChanged( false ), |
| 9 | bIsLoaded( false ) | 9 | bIsLoaded( false ) |
| 10 | { | 10 | { |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | Cache::~Cache() | 13 | Cache::~Cache() |
| 14 | { | 14 | { |
| 15 | save(); | 15 | save(); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | void Cache::bind( const Bu::String &sCacheFile ) | 18 | void Cache::bind( const Bu::String &sCacheFile ) |
| 19 | { | 19 | { |
| 20 | this->sCacheFile = sCacheFile; | 20 | this->sCacheFile = sCacheFile; |
| 21 | load(); | 21 | load(); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | void Cache::load() | 24 | void Cache::load() |
| 25 | { | 25 | { |
| 26 | if( bIsLoaded ) | 26 | if( bIsLoaded ) |
| 27 | return; | 27 | return; |
| 28 | 28 | ||
| 29 | try | 29 | try |
| 30 | { | 30 | { |
| 31 | Bu::File fIn( sCacheFile, Bu::File::Read ); | 31 | Bu::File fIn( sCacheFile, Bu::File::Read ); |
| 32 | Bu::Archive ar( fIn, Bu::Archive::load ); | 32 | Bu::Archive ar( fIn, Bu::Archive::load ); |
| 33 | 33 | ||
| 34 | ar >> hRequires >> hVariables; | 34 | ar >> hRequires >> hVariables; |
| 35 | } | 35 | } |
| 36 | catch(...) { } | 36 | catch(...) { } |
| 37 | 37 | ||
| 38 | bIsLoaded = true; | 38 | bIsLoaded = true; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void Cache::save() | 41 | void Cache::save() |
| 42 | { | 42 | { |
| 43 | if( !bIsLoaded ) | 43 | if( !bIsLoaded ) |
| 44 | return; | 44 | return; |
| 45 | if( bCacheChanged == false ) | 45 | if( bCacheChanged == false ) |
| 46 | return; | 46 | return; |
| 47 | 47 | ||
| 48 | Bu::File fIn( sCacheFile, Bu::File::WriteNew ); | 48 | Bu::File fIn( sCacheFile, Bu::File::WriteNew ); |
| 49 | Bu::Archive ar( fIn, Bu::Archive::save ); | 49 | Bu::Archive ar( fIn, Bu::Archive::save ); |
| 50 | 50 | ||
| 51 | ar << hRequires << hVariables; | 51 | ar << hRequires << hVariables; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | StrList Cache::getRequires( const Bu::String &sOutput ) | 54 | StrList Cache::getRequires( const Bu::String &sOutput ) |
| 55 | { | 55 | { |
| 56 | return hRequires.get( sOutput ); | 56 | return hRequires.get( sOutput ); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | void Cache::setRequires( const Bu::String &sOutput, StrList lReqs ) | 59 | void Cache::setRequires( const Bu::String &sOutput, StrList lReqs ) |
| 60 | { | 60 | { |
| 61 | hRequires.insert( sOutput, lReqs ); | 61 | hRequires.insert( sOutput, lReqs ); |
| 62 | bCacheChanged = true; | 62 | bCacheChanged = true; |
| 63 | } | 63 | } |
| 64 | 64 | ||
