aboutsummaryrefslogtreecommitdiff
path: root/src/cache.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-01-04 23:24:55 +0000
committerMike Buland <eichlan@xagasoft.com>2010-01-04 23:24:55 +0000
commitabe69082514b61181c6bc15a341895c971ecdc43 (patch)
treeffeb8791f5b95ba13c7c05f3c0d434c1755910dd /src/cache.cpp
parentff9e70dfa03fa1fb21bbb6d7de5a8fd85f31bba3 (diff)
downloadbuild-abe69082514b61181c6bc15a341895c971ecdc43.tar.gz
build-abe69082514b61181c6bc15a341895c971ecdc43.tar.bz2
build-abe69082514b61181c6bc15a341895c971ecdc43.tar.xz
build-abe69082514b61181c6bc15a341895c971ecdc43.zip
The cache works...really well.
Diffstat (limited to 'src/cache.cpp')
-rw-r--r--src/cache.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/cache.cpp b/src/cache.cpp
index 1646d0a..de505b8 100644
--- a/src/cache.cpp
+++ b/src/cache.cpp
@@ -1,14 +1,18 @@
1#include "cache.h" 1#include "cache.h"
2#include <bu/file.h> 2#include <bu/file.h>
3#include <bu/archive.h> 3#include <bu/archive.h>
4#include <bu/sio.h>
5using namespace Bu;
4 6
5Cache::Cache() : 7Cache::Cache() :
8 bCacheChanged( false ),
6 bIsLoaded( false ) 9 bIsLoaded( false )
7{ 10{
8} 11}
9 12
10Cache::~Cache() 13Cache::~Cache()
11{ 14{
15 save();
12} 16}
13 17
14void Cache::bind( const Bu::FString &sCacheFile ) 18void Cache::bind( const Bu::FString &sCacheFile )
@@ -21,19 +25,40 @@ void Cache::load()
21{ 25{
22 if( bIsLoaded ) 26 if( bIsLoaded )
23 return; 27 return;
24 Bu::File fIn( sCacheFile, Bu::File::Read );
25 Bu::Archive ar( fIn, Bu::Archive::load );
26 28
27 ar >> hRequires >> hVariables; 29 try
30 {
31 Bu::File fIn( sCacheFile, Bu::File::Read );
32 Bu::Archive ar( fIn, Bu::Archive::load );
33
34 ar >> hRequires >> hVariables;
35 }
36 catch(...) { }
28 37
29 bIsLoaded = true; 38 bIsLoaded = true;
30} 39}
31 40
32void Cache::save() 41void Cache::save()
33{ 42{
43 if( !bIsLoaded )
44 return;
45 if( bCacheChanged == false )
46 return;
47
34 Bu::File fIn( sCacheFile, Bu::File::WriteNew ); 48 Bu::File fIn( sCacheFile, Bu::File::WriteNew );
35 Bu::Archive ar( fIn, Bu::Archive::save ); 49 Bu::Archive ar( fIn, Bu::Archive::save );
36 50
37 ar << hRequires << hVariables; 51 ar << hRequires << hVariables;
38} 52}
39 53
54StrList Cache::getRequires( const Bu::FString &sOutput )
55{
56 return hRequires.get( sOutput );
57}
58
59void Cache::setRequires( const Bu::FString &sOutput, StrList lReqs )
60{
61 hRequires.insert( sOutput, lReqs );
62 bCacheChanged = true;
63}
64