@@ -15,6 +15,15 @@ namespace fs = boost::filesystem;
15
15
16
16
namespace rime {
17
17
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
+
18
27
CustomSettings::CustomSettings (Deployer* deployer,
19
28
const string& config_id,
20
29
const string& generator_id)
@@ -34,7 +43,7 @@ bool CustomSettings::Load() {
34
43
return false ;
35
44
}
36
45
}
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_));
38
47
custom_config_.LoadFromFile (custom_config_path.string ());
39
48
modified_ = false ;
40
49
return true ;
@@ -46,7 +55,7 @@ bool CustomSettings::Save() {
46
55
Signature signature (generator_id_, " customization" );
47
56
signature.Sign (&custom_config_, deployer_);
48
57
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_) ;
50
59
custom_config_.SaveToFile (custom_config_path.string ());
51
60
modified_ = false ;
52
61
return true ;
@@ -80,7 +89,7 @@ bool CustomSettings::Customize(const string& key,
80
89
81
90
bool CustomSettings::IsFirstRun () {
82
91
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_) ;
84
93
Config config;
85
94
if (!config.LoadFromFile (custom_config_path.string ()))
86
95
return true ;
0 commit comments