diff options
Diffstat (limited to 'src/cache.cpp')
-rw-r--r-- | src/cache.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cache.cpp b/src/cache.cpp new file mode 100644 index 0000000..1646d0a --- /dev/null +++ b/src/cache.cpp | |||
@@ -0,0 +1,39 @@ | |||
1 | #include "cache.h" | ||
2 | #include <bu/file.h> | ||
3 | #include <bu/archive.h> | ||
4 | |||
5 | Cache::Cache() : | ||
6 | bIsLoaded( false ) | ||
7 | { | ||
8 | } | ||
9 | |||
10 | Cache::~Cache() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | void Cache::bind( const Bu::FString &sCacheFile ) | ||
15 | { | ||
16 | this->sCacheFile = sCacheFile; | ||
17 | load(); | ||
18 | } | ||
19 | |||
20 | void Cache::load() | ||
21 | { | ||
22 | if( bIsLoaded ) | ||
23 | return; | ||
24 | Bu::File fIn( sCacheFile, Bu::File::Read ); | ||
25 | Bu::Archive ar( fIn, Bu::Archive::load ); | ||
26 | |||
27 | ar >> hRequires >> hVariables; | ||
28 | |||
29 | bIsLoaded = true; | ||
30 | } | ||
31 | |||
32 | void Cache::save() | ||
33 | { | ||
34 | Bu::File fIn( sCacheFile, Bu::File::WriteNew ); | ||
35 | Bu::Archive ar( fIn, Bu::Archive::save ); | ||
36 | |||
37 | ar << hRequires << hVariables; | ||
38 | } | ||
39 | |||