Skip to content

Commit 4d8bb87

Browse files
committed
chore: use path::u8string for filename comparison
1 parent 060555c commit 4d8bb87

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/rime/gear/simplifier.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Simplifier::Simplifier(const Ticket& ticket)
197197
void Simplifier::Initialize() {
198198
initialized_ = true; // no retry
199199
path opencc_config_path = path(opencc_config_);
200-
if (opencc_config_path.extension().string() == ".ini") {
200+
if (opencc_config_path.extension().u8string() == ".ini") {
201201
LOG(ERROR) << "please upgrade opencc_config to an opencc 1.0 config file.";
202202
return;
203203
}

src/rime/lever/deployment_tasks.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ bool DetectModifications::Run(Deployer* deployer) {
5454
for (fs::directory_iterator iter(p), end; iter != end; ++iter) {
5555
path entry(iter->path());
5656
if (fs::is_regular_file(fs::canonical(entry)) &&
57-
entry.extension().string() == ".yaml" &&
58-
entry.filename().string() != "user.yaml") {
57+
entry.extension().u8string() == ".yaml" &&
58+
entry.filename().u8string() != "user.yaml") {
5959
last_modified =
6060
(std::max)(last_modified,
6161
filesystem::to_time_t(fs::last_write_time(entry)));
@@ -458,7 +458,7 @@ bool PrebuildAllSchemas::Run(Deployer* deployer) {
458458
for (fs::directory_iterator iter(shared_data_path), end; iter != end;
459459
++iter) {
460460
path entry(iter->path());
461-
if (boost::ends_with(entry.filename().string(), ".schema.yaml")) {
461+
if (boost::ends_with(entry.filename().u8string(), ".schema.yaml")) {
462462
the<DeploymentTask> t(new SchemaUpdate(entry));
463463
if (!t->Run(deployer))
464464
success = false;
@@ -523,7 +523,7 @@ bool UserDictSync::Run(Deployer* deployer) {
523523
}
524524

525525
static bool IsCustomizedCopy(const path& file_path) {
526-
auto file_name = file_path.filename().string();
526+
auto file_name = file_path.filename().u8string();
527527
if (boost::ends_with(file_name, ".yaml") &&
528528
!boost::ends_with(file_name, ".custom.yaml")) {
529529
Config config;
@@ -550,7 +550,7 @@ bool BackupConfigFiles::Run(Deployer* deployer) {
550550
path entry(iter->path());
551551
if (!fs::is_regular_file(entry))
552552
continue;
553-
auto file_extension = entry.extension().string();
553+
auto file_extension = entry.extension().u8string();
554554
bool is_yaml_file = file_extension == ".yaml";
555555
bool is_text_file = file_extension == ".txt";
556556
if (!is_yaml_file && !is_text_file)
@@ -590,7 +590,7 @@ bool CleanupTrash::Run(Deployer* deployer) {
590590
path entry(iter->path());
591591
if (!fs::is_regular_file(entry))
592592
continue;
593-
auto file_name = entry.filename().string();
593+
auto file_name = entry.filename().u8string();
594594
if (file_name == "rime.log" || boost::ends_with(file_name, ".bin") ||
595595
boost::ends_with(file_name, ".reverse.kct") ||
596596
boost::ends_with(file_name, ".userdb.kct.old") ||
@@ -643,7 +643,7 @@ bool CleanOldLogFiles::Run(Deployer* deployer) {
643643
try {
644644
// preparing files
645645
for (const auto& entry : fs::directory_iterator(dir)) {
646-
const string& file_name(entry.path().filename().string());
646+
const string& file_name(entry.path().filename().u8string());
647647
if (entry.is_regular_file() && !entry.is_symlink() &&
648648
boost::starts_with(file_name, app_name) &&
649649
boost::ends_with(file_name, ".log") &&

src/rime/lever/switcher_settings.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void SwitcherSettings::GetAvailableSchemasFromDirectory(const path& dir) {
5454
}
5555
for (fs::directory_iterator it(dir), end; it != end; ++it) {
5656
path file_path(it->path());
57-
if (boost::ends_with(file_path.string(), ".schema.yaml")) {
57+
if (boost::ends_with(file_path.u8string(), ".schema.yaml")) {
5858
Config config;
5959
if (config.LoadFromFile(file_path)) {
6060
SchemaInfo info;
@@ -86,6 +86,7 @@ void SwitcherSettings::GetAvailableSchemasFromDirectory(const path& dir) {
8686
}
8787
}
8888
config.GetString("schema/description", &info.description);
89+
// output path in native encoding.
8990
info.file_path = file_path.string();
9091
available_.push_back(info);
9192
}

0 commit comments

Comments
 (0)