@@ -15,6 +15,15 @@ namespace fs = boost::filesystem;
1515
1616namespace rime {
1717
18+ static string remove_suffix (const string& input, const string& suffix) {
19+ return boost::ends_with (input, suffix) ?
20+ input.substr (0 , input.length () - suffix.length ()) : input;
21+ }
22+
23+ static string custom_config_file (const string& config_id) {
24+ return remove_suffix (config_id, " .schema" ) + " .custom.yaml" ;
25+ }
26+
1827CustomSettings::CustomSettings (Deployer* deployer,
1928 const string& config_id,
2029 const string& generator_id)
@@ -34,7 +43,7 @@ bool CustomSettings::Load() {
3443 return false ;
3544 }
3645 }
37- fs::path custom_config_path (user_data_path / (config_id_ + " .custom.yaml " ));
46+ fs::path custom_config_path (user_data_path / custom_config_file (config_id_));
3847 custom_config_.LoadFromFile (custom_config_path.string ());
3948 modified_ = false ;
4049 return true ;
@@ -46,7 +55,7 @@ bool CustomSettings::Save() {
4655 Signature signature (generator_id_, " customization" );
4756 signature.Sign (&custom_config_, deployer_);
4857 fs::path custom_config_path (deployer_->user_data_dir );
49- custom_config_path /= config_id_ + " .custom.yaml " ;
58+ custom_config_path /= custom_config_file ( config_id_) ;
5059 custom_config_.SaveToFile (custom_config_path.string ());
5160 modified_ = false ;
5261 return true ;
@@ -80,7 +89,7 @@ bool CustomSettings::Customize(const string& key,
8089
8190bool CustomSettings::IsFirstRun () {
8291 fs::path custom_config_path (deployer_->user_data_dir );
83- custom_config_path /= config_id_ + " .custom.yaml " ;
92+ custom_config_path /= custom_config_file ( config_id_) ;
8493 Config config;
8594 if (!config.LoadFromFile (custom_config_path.string ()))
8695 return true ;
0 commit comments