From 8601c79647333079aab4d80f4dee681938108232 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Thu, 19 Jun 2014 19:42:27 -0400 Subject: [PATCH] Cache the config cache files prefix No pun intended. This micro-refactoring step will be required for introducing functionality that requires to know the config cache files' naming pattern. --- src/config_cache.cpp | 14 ++++++++++---- src/config_cache.hpp | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/config_cache.cpp b/src/config_cache.cpp index 0d575732abc4..5a98f61c5fbc 100644 --- a/src/config_cache.cpp +++ b/src/config_cache.cpp @@ -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(); } @@ -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; diff --git a/src/config_cache.hpp b/src/config_cache.hpp index cff4a2102cda..4e14cb1c5f23 100644 --- a/src/config_cache.hpp +++ b/src/config_cache.hpp @@ -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&);