22
22
#include < rime/resource.h>
23
23
#include < rime/service.h>
24
24
25
- namespace fs = std::filesystem;
26
-
27
25
namespace rime {
28
26
29
27
DictCompiler::DictCompiler (Dictionary* dictionary)
@@ -39,7 +37,7 @@ DictCompiler::DictCompiler(Dictionary* dictionary)
39
37
DictCompiler::~DictCompiler () {}
40
38
41
39
static bool load_dict_settings_from_file (DictSettings* settings,
42
- const fs:: path& dict_file) {
40
+ const path& dict_file) {
43
41
std::ifstream fin (dict_file.string ().c_str ());
44
42
bool success = settings->LoadDictHeader (fin);
45
43
fin.close ();
@@ -53,7 +51,7 @@ static bool get_dict_files_from_settings(vector<string>* dict_files,
53
51
for (auto it = tables->begin (); it != tables->end (); ++it) {
54
52
string dict_name = As<ConfigValue>(*it)->str ();
55
53
auto dict_file = source_resolver->ResolvePath (dict_name + " .dict.yaml" );
56
- if (!fs ::exists (dict_file)) {
54
+ if (!std::filesystem ::exists (dict_file)) {
57
55
LOG (ERROR) << " source file '" << dict_file << " ' does not exist." ;
58
56
return false ;
59
57
}
@@ -162,7 +160,7 @@ bool DictCompiler::Compile(const string& schema_file) {
162
160
EntryCollector collector (std::move (syllabary));
163
161
DictSettings settings;
164
162
auto dict_file = source_resolver_->ResolvePath (pack_name + " .dict.yaml" );
165
- if (!fs ::exists (dict_file)) {
163
+ if (!std::filesystem ::exists (dict_file)) {
166
164
LOG (ERROR) << " source file '" << dict_file << " ' does not exist." ;
167
165
continue ;
168
166
}
@@ -188,8 +186,8 @@ bool DictCompiler::Compile(const string& schema_file) {
188
186
return true ;
189
187
}
190
188
191
- static fs:: path relocate_target (const fs:: path& source_path,
192
- ResourceResolver* target_resolver) {
189
+ static path relocate_target (const path& source_path,
190
+ ResourceResolver* target_resolver) {
193
191
auto resource_id = source_path.filename ().string ();
194
192
return target_resolver->ResolvePath (resource_id);
195
193
}
@@ -208,7 +206,7 @@ bool DictCompiler::BuildTable(int table_index,
208
206
collector.Configure (settings);
209
207
collector.Collect (dict_files);
210
208
if (options_ & kDump ) {
211
- fs:: path dump_path (table->file_name ());
209
+ path dump_path (table->file_name ());
212
210
dump_path.replace_extension (" .txt" );
213
211
collector.Dump (dump_path.string ());
214
212
}
@@ -313,7 +311,7 @@ bool DictCompiler::BuildPrism(const string& schema_file,
313
311
bool enable_correction = false; // Avoid if initializer to comfort compilers
314
312
if (config.GetBool("translator/enable_correction", &enable_correction) &&
315
313
enable_correction) {
316
- fs:: path corrector_path(prism_->file_name());
314
+ path corrector_path(prism_->file_name());
317
315
corrector_path.replace_extension("");
318
316
corrector_path.replace_extension(".correction.bin");
319
317
auto target_path = relocate_target(corrector_path,
@@ -331,9 +329,9 @@ bool DictCompiler::BuildPrism(const string& schema_file,
331
329
#endif
332
330
}
333
331
if ((options_ & kDump ) && !script.empty ()) {
334
- fs:: path path (prism_->file_name ());
335
- path .replace_extension (" .txt" );
336
- script.Dump (path .string ());
332
+ path dump_path (prism_->file_name ());
333
+ dump_path .replace_extension (" .txt" );
334
+ script.Dump (dump_path .string ());
337
335
}
338
336
// build .prism.bin
339
337
{
0 commit comments