Skip to content

Commit

Permalink
Cache the config cache files prefix
Browse files Browse the repository at this point in the history
No pun intended.

This micro-refactoring step will be required for introducing
functionality that requires to know the config cache files' naming
pattern.
  • Loading branch information
irydacea committed Jun 20, 2014
1 parent 2415df7 commit 8601c79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/config_cache.cpp
Expand Up @@ -48,8 +48,15 @@ namespace game_config {
force_valid_cache_(false),
use_cache_(true),
fake_invalid_cache_(false),
defines_map_()
defines_map_(),
cache_file_prefix_()
{
cache_file_prefix_
= "cache-v" +
boost::algorithm::replace_all_copy(game_config::revision,
":", "_") +
"-";

// To set-up initial defines map correctly
clear_defines();
}
Expand Down Expand Up @@ -177,9 +184,8 @@ namespace game_config {
const std::string& cache = get_cache_dir();
if(cache != "") {
sha1_hash sha(defines_string.str()); // use a hash for a shorter display of the defines
const std::string fname = cache + "/cache-v" +
boost::algorithm::replace_all_copy(game_config::revision, ":", "_") +
"-" + sha.display();
const std::string fname = cache + "/" +
cache_file_prefix_ + sha.display();
const std::string fname_checksum = fname + ".checksum" + extension;

file_tree_checksum dir_checksum;
Expand Down
2 changes: 2 additions & 0 deletions src/config_cache.hpp
Expand Up @@ -83,6 +83,8 @@ namespace game_config {
bool force_valid_cache_, use_cache_, fake_invalid_cache_;
preproc_map defines_map_;

std::string cache_file_prefix_;

void read_file(const std::string& file, config& cfg);
void write_file(std::string file, const config& cfg);
void write_file(std::string file, const preproc_map&);
Expand Down

0 comments on commit 8601c79

Please sign in to comment.