Index: librime-1.14.0/CMakeLists.txt =================================================================== --- librime-1.14.0.orig/CMakeLists.txt +++ librime-1.14.0/CMakeLists.txt @@ -60,7 +60,7 @@ if(MSVC) endif() if(LINUX) - find_package(Boost 1.74.0 REQUIRED COMPONENTS regex) + find_package(Boost 1.66.0 REQUIRED COMPONENTS regex filesystem) else() find_package(Boost 1.77.0) endif() Index: librime-1.14.0/plugins/plugins_module.cc =================================================================== --- librime-1.14.0.orig/plugins/plugins_module.cc +++ librime-1.14.0/plugins/plugins_module.cc @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -14,7 +14,7 @@ #include #include -namespace fs = std::filesystem; +namespace fs = boost::filesystem; namespace rime { Index: librime-1.14.0/src/rime/common.h =================================================================== --- librime-1.14.0.orig/src/rime/common.h +++ librime-1.14.0/src/rime/common.h @@ -9,7 +9,7 @@ #include -#include +#include #include #include #include @@ -79,8 +79,9 @@ inline an New(Args&&... args) { using boost::signals2::connection; using boost::signals2::signal; -class path : public std::filesystem::path { - using fs_path = std::filesystem::path; +class path : public boost::filesystem::path { + + using fs_path = boost::filesystem::path; public: path() : fs_path() {} @@ -89,9 +90,9 @@ class path : public std::filesystem::pat #ifdef _WIN32 // convert utf-8 string to native encoding path. explicit path(const std::string& utf8_path) - : fs_path(std::filesystem::u8path(utf8_path)) {} + : fs_path(boost::filesystem::path(utf8_path)) {} explicit path(const char* utf8_path) - : fs_path(std::filesystem::u8path(utf8_path)) {} + : fs_path(boost::filesystem::path(utf8_path)) {} #else // disable implicit conversion from string to path for development purpose. explicit path(const std::string& utf8_path) : fs_path(utf8_path) {} @@ -126,6 +127,9 @@ class path : public std::filesystem::pat friend path operator/(const fs_path& lhs, const char* rhs) { return path(lhs) /= path(rhs); } + const std::string & u8string() const { + return this->string(); + } #ifdef RIME_ENABLE_LOGGING friend std::ostream& operator<<(std::ostream& os, const path& p) { return os << p.u8string(); Index: librime-1.14.0/src/rime/config/build_info_plugin.cc =================================================================== --- librime-1.14.0.orig/src/rime/config/build_info_plugin.cc +++ librime-1.14.0/src/rime/config/build_info_plugin.cc @@ -2,7 +2,7 @@ // Copyright RIME Developers // Distributed under the BSD License // -#include +#include #include #include #include @@ -37,7 +37,7 @@ bool BuildInfoPlugin::ReviewLinkOutput(C } // TODO: store as 64-bit number to avoid the year 2038 problem timestamps[resource->resource_id] = - (int)filesystem::to_time_t(std::filesystem::last_write_time(file_path)); + (int)boost::filesystem::last_write_time(file_path); }); #endif return true; Index: librime-1.14.0/src/rime/config/config_data.cc =================================================================== --- librime-1.14.0.orig/src/rime/config/config_data.cc +++ librime-1.14.0/src/rime/config/config_data.cc @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -65,8 +65,8 @@ bool ConfigData::LoadFromFile(const path file_path_ = file_path; modified_ = false; root.reset(); - if (!std::filesystem::exists(file_path)) { - if (!boost::ends_with(file_path.u8string(), ".custom.yaml")) + if (!boost::filesystem::exists(file_path)) { + if (!boost::ends_with(file_path.string(), ".custom.yaml")) LOG(WARNING) << "nonexistent config file '" << file_path << "'."; return false; } Index: librime-1.14.0/src/rime/dict/db.cc =================================================================== --- librime-1.14.0.orig/src/rime/dict/db.cc +++ librime-1.14.0/src/rime/dict/db.cc @@ -5,7 +5,7 @@ // 2011-11-02 GONG Chen // #include -#include +#include #include #include #include @@ -40,7 +40,7 @@ Db::Db(const path& file_path, const stri : name_(name), file_path_(file_path) {} bool Db::Exists() const { - return std::filesystem::exists(file_path()); + return boost::filesystem::exists(file_path()); } bool Db::Remove() { @@ -48,7 +48,7 @@ bool Db::Remove() { LOG(ERROR) << "attempt to remove opened db '" << name_ << "'."; return false; } - return std::filesystem::remove(file_path()); + return boost::filesystem::remove(file_path()); } bool Db::CreateMetadata() { Index: librime-1.14.0/src/rime/dict/dict_compiler.cc =================================================================== --- librime-1.14.0.orig/src/rime/dict/dict_compiler.cc +++ librime-1.14.0/src/rime/dict/dict_compiler.cc @@ -4,7 +4,7 @@ // // 2011-11-27 GONG Chen // -#include +#include #include #include #include @@ -51,7 +51,7 @@ static bool get_dict_files_from_settings for (auto it = tables->begin(); it != tables->end(); ++it) { string dict_name = As(*it)->str(); auto dict_file = source_resolver->ResolvePath(dict_name + ".dict.yaml"); - if (!std::filesystem::exists(dict_file)) { + if (!boost::filesystem::exists(dict_file)) { LOG(ERROR) << "source file '" << dict_file << "' does not exist."; return false; } @@ -82,7 +82,7 @@ bool DictCompiler::Compile(const path& s bool build_table_from_source = true; DictSettings settings; auto dict_file = source_resolver_->ResolvePath(dict_name_ + ".dict.yaml"); - if (!std::filesystem::exists(dict_file)) { + if (!boost::filesystem::exists(dict_file)) { LOG(ERROR) << "source file '" << dict_file << "' does not exist."; build_table_from_source = false; } else if (!load_dict_settings_from_file(&settings, dict_file)) { @@ -165,7 +165,7 @@ bool DictCompiler::Compile(const path& s EntryCollector collector(std::move(syllabary)); DictSettings settings; auto dict_file = source_resolver_->ResolvePath(pack_name + ".dict.yaml"); - if (!std::filesystem::exists(dict_file)) { + if (!boost::filesystem::exists(dict_file)) { if (pack_table->Exists()) LOG(INFO) << "pack source file '" << dict_file << "' does not exist, using prebuilt table '" @@ -209,7 +209,7 @@ bool DictCompiler::Compile(const path& s static path relocate_target(const path& source_path, ResourceResolver* target_resolver) { - auto resource_id = source_path.filename().u8string(); + auto resource_id = source_path.filename().string(); return target_resolver->ResolvePath(resource_id); } Index: librime-1.14.0/src/rime/dict/dictionary.cc =================================================================== --- librime-1.14.0.orig/src/rime/dict/dictionary.cc +++ librime-1.14.0/src/rime/dict/dictionary.cc @@ -4,7 +4,7 @@ // // 2011-07-05 GONG Chen // -#include +#include #include #include #include @@ -352,8 +352,8 @@ bool Dictionary::Decode(const Code& code } bool Dictionary::Exists() const { - return std::filesystem::exists(prism_->file_path()) && !tables_.empty() && - std::filesystem::exists(tables_[0]->file_path()); + return boost::filesystem::exists(prism_->file_path()) && !tables_.empty() && + boost::filesystem::exists(tables_[0]->file_path()); } bool Dictionary::Remove() { Index: librime-1.14.0/src/rime/dict/mapped_file.cc =================================================================== --- librime-1.14.0.orig/src/rime/dict/mapped_file.cc +++ librime-1.14.0/src/rime/dict/mapped_file.cc @@ -7,7 +7,7 @@ // 2011-06-30 GONG Chen // #include -#include +#include #include #include #include @@ -101,7 +101,7 @@ void MappedFile::Close() { } bool MappedFile::Exists() const { - return std::filesystem::exists(file_path_); + return boost::filesystem::exists(file_path_); } bool MappedFile::IsOpen() const { @@ -130,7 +130,7 @@ bool MappedFile::Resize(size_t capacity) if (IsOpen()) Close(); try { - std::filesystem::resize_file(file_path_, capacity); + boost::filesystem::resize_file(file_path_, capacity); } catch (...) { return false; } Index: librime-1.14.0/src/rime/dict/user_db.cc =================================================================== --- librime-1.14.0.orig/src/rime/dict/user_db.cc +++ librime-1.14.0/src/rime/dict/user_db.cc @@ -107,7 +107,7 @@ bool UserDbHelper::UpdateUserInfo() { } bool UserDbHelper::IsUniformFormat(const path& file_path) { - return boost::ends_with(file_path.filename().u8string(), + return boost::ends_with(file_path.filename().string(), plain_userdb_extension); } Index: librime-1.14.0/src/rime/dict/user_db_recovery_task.cc =================================================================== --- librime-1.14.0.orig/src/rime/dict/user_db_recovery_task.cc +++ librime-1.14.0/src/rime/dict/user_db_recovery_task.cc @@ -5,7 +5,7 @@ // 2013-04-22 GONG Chen // #include -#include +#include #include #include #include @@ -40,9 +40,9 @@ bool UserDbRecoveryTask::Run(Deployer* d // repair didn't work on the damaged db file; remove and recreate it LOG(INFO) << "recreating db file."; if (db_->Exists()) { - std::error_code ec; - std::filesystem::rename(db_->file_path(), - path(db_->file_path()).concat(".old"), ec); + boost::system::error_code ec; + boost::filesystem::rename(db_->file_path(), + path(db_->file_path()) /= ".old", ec); if (ec && !db_->Remove()) { LOG(ERROR) << "Error removing db file '" << db_->file_path() << "'."; return false; @@ -67,12 +67,12 @@ void UserDbRecoveryTask::RestoreUserData const path& dir(deployer->user_data_sync_dir()); // try *.userdb.txt path snapshot_path = dir / (dict_name + UserDb::snapshot_extension()); - if (!std::filesystem::exists(snapshot_path)) { + if (!boost::filesystem::exists(snapshot_path)) { // try *.userdb.*.snapshot string legacy_snapshot_file = dict_name + component->extension() + ".snapshot"; snapshot_path = dir / legacy_snapshot_file; - if (!std::filesystem::exists(snapshot_path)) { + if (!boost::filesystem::exists(snapshot_path)) { return; // not found } } Index: librime-1.14.0/src/rime/gear/simplifier.cc =================================================================== --- librime-1.14.0.orig/src/rime/gear/simplifier.cc +++ librime-1.14.0/src/rime/gear/simplifier.cc @@ -36,7 +36,7 @@ class Opencc { opencc::Config config; try { // opencc accepts file path encoded in UTF-8. - converter_ = config.NewFromFile(config_path.u8string()); + converter_ = config.NewFromFile(config_path.string()); const list conversions = converter_->GetConversionChain()->GetConversions(); @@ -305,7 +305,7 @@ Simplifier* SimplifierComponent::Create( return new Simplifier(ticket, opencc); } path opencc_config_path = path(opencc_config); - if (opencc_config_path.extension().u8string() == ".ini") { + if (opencc_config_path.extension().string() == ".ini") { LOG(ERROR) << "please upgrade opencc_config to an opencc 1.0 config file."; return nullptr; } Index: librime-1.14.0/src/rime/lever/customizer.cc =================================================================== --- librime-1.14.0.orig/src/rime/lever/customizer.cc +++ librime-1.14.0/src/rime/lever/customizer.cc @@ -4,14 +4,14 @@ // // 2011-12-12 GONG Chen // -#include +#include #include #include #include #include #include -namespace fs = std::filesystem; +namespace fs = boost::filesystem; namespace rime { @@ -88,7 +88,7 @@ bool Customizer::UpdateConfigFile() { if (redistribute || (is_dirty && !missing_original_copy)) { try { fs::copy_file(source_path_, dest_path_, - fs::copy_options::overwrite_existing); + fs::copy_option::overwrite_if_exists); } catch (...) { LOG(ERROR) << "Error copying config file '" << source_path_ << "' to user directory."; Index: librime-1.14.0/src/rime/lever/deployment_tasks.cc =================================================================== --- librime-1.14.0.orig/src/rime/lever/deployment_tasks.cc +++ librime-1.14.0/src/rime/lever/deployment_tasks.cc @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ #include #endif -namespace fs = std::filesystem; +namespace fs = boost::filesystem; namespace rime { @@ -47,16 +47,16 @@ bool DetectModifications::Run(Deployer* for (auto dir : data_dirs_) { path p = fs::canonical(dir); last_modified = (std::max)(last_modified, - filesystem::to_time_t(fs::last_write_time(p))); + fs::last_write_time(p)); if (fs::is_directory(p)) { for (fs::directory_iterator iter(p), end; iter != end; ++iter) { path entry(iter->path()); if (fs::is_regular_file(fs::canonical(entry)) && - entry.extension().u8string() == ".yaml" && - entry.filename().u8string() != "user.yaml") { + entry.extension().string() == ".yaml" && + entry.filename().string() != "user.yaml") { last_modified = (std::max)(last_modified, - filesystem::to_time_t(fs::last_write_time(entry))); + fs::last_write_time(entry)); } } } @@ -85,7 +85,7 @@ bool InstallationUpdate::Run(Deployer* d const path& user_data_path(deployer->user_data_dir); if (!fs::exists(user_data_path)) { LOG(INFO) << "creating user data dir: " << user_data_path; - std::error_code ec; + boost::system::error_code ec; if (!fs::create_directories(user_data_path, ec)) { LOG(ERROR) << "Error creating user data dir: " << user_data_path; } @@ -263,7 +263,7 @@ SchemaUpdate::SchemaUpdate(TaskInitializ } static bool MaybeCreateDirectory(path dir) { - std::error_code ec; + boost::system::error_code ec; if (fs::create_directories(dir, ec)) { return true; } @@ -314,7 +314,7 @@ static bool TrashDeprecatedUserCopy(cons return false; } path backup = trash / user_copy.filename(); - std::error_code ec; + boost::system::error_code ec; fs::rename(user_copy, backup, ec); if (ec) { LOG(ERROR) << "error trashing file " << user_copy; @@ -419,7 +419,7 @@ static bool ConfigNeedsUpdate(Config* co continue; } if (recorded_time != - (int)filesystem::to_time_t(fs::last_write_time(source_file))) { + (int)fs::last_write_time(source_file)) { LOG(INFO) << "source file " << (recorded_time ? "changed: " : "added: ") << source_file; return true; @@ -460,7 +460,7 @@ bool PrebuildAllSchemas::Run(Deployer* d for (fs::directory_iterator iter(shared_data_path), end; iter != end; ++iter) { path entry(iter->path()); - if (boost::ends_with(entry.filename().u8string(), ".schema.yaml")) { + if (boost::ends_with(entry.filename().string(), ".schema.yaml")) { the t(new SchemaUpdate(entry)); if (!t->Run(deployer)) success = false; @@ -483,7 +483,7 @@ bool SymlinkingPrebuiltDictionaries::Run if (fs::is_symlink(entry)) { try { // a symlink becomes dangling if the target file is no longer provided - std::error_code ec; + boost::system::error_code ec; auto target_path = fs::canonical(entry, ec); bool bad_link = bool(ec); bool linked_to_shared_data = @@ -525,7 +525,7 @@ bool UserDictSync::Run(Deployer* deploye } static bool IsCustomizedCopy(const path& file_path) { - auto file_name = file_path.filename().u8string(); + auto file_name = file_path.filename().string(); if (boost::ends_with(file_name, ".yaml") && !boost::ends_with(file_name, ".custom.yaml")) { Config config; @@ -556,7 +556,7 @@ bool BackupConfigFiles::Run(Deployer* de path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; - auto file_extension = entry.extension().u8string(); + auto file_extension = entry.extension().string(); bool is_yaml_file = file_extension == ".yaml"; bool is_text_file = file_extension == ".txt"; if (!is_yaml_file && !is_text_file) @@ -570,8 +570,8 @@ bool BackupConfigFiles::Run(Deployer* de ++skipped; // customized copy continue; } - std::error_code ec; - fs::copy_file(entry, backup, fs::copy_options::overwrite_existing, ec); + boost::system::error_code ec; + fs::copy_file(entry, backup, fs::copy_option::overwrite_if_exists, ec); if (ec) { LOG(ERROR) << "error backing up file " << backup; ++failure; @@ -596,7 +596,7 @@ bool CleanupTrash::Run(Deployer* deploye path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; - auto file_name = entry.filename().u8string(); + auto file_name = entry.filename().string(); if (file_name == "rime.log" || boost::ends_with(file_name, ".bin") || boost::ends_with(file_name, ".reverse.kct") || boost::ends_with(file_name, ".userdb.kct.old") || @@ -605,7 +605,7 @@ bool CleanupTrash::Run(Deployer* deploye return false; } path backup = trash / entry.filename(); - std::error_code ec; + boost::system::error_code ec; fs::rename(entry, backup, ec); if (ec) { LOG(ERROR) << "error clean up file " << entry; @@ -650,15 +650,15 @@ bool CleanOldLogFiles::Run(Deployer* dep try { // preparing files for (const auto& entry : fs::directory_iterator(dir)) { - const string& file_name(entry.path().filename().u8string()); - if (entry.is_regular_file() && !entry.is_symlink() && + const string& file_name(entry.path().filename().string()); + if (fs::is_regular_file(entry.path()) && !fs::is_symlink(entry.path()) && boost::starts_with(file_name, app_name) && boost::ends_with(file_name, ".log") && !boost::contains(file_name, today)) { files_to_remove.push_back(entry.path()); - } else if (entry.is_symlink()) { + } else if (fs::is_symlink(entry.path())) { auto target = fs::read_symlink(entry.path()); - const string& target_file_name(target.filename().u8string()); + const string& target_file_name(target.filename().string()); if (boost::starts_with(target_file_name, app_name) && boost::ends_with(target_file_name, ".log")) { files_in_use.insert(target); Index: librime-1.14.0/src/rime/lever/switcher_settings.cc =================================================================== --- librime-1.14.0.orig/src/rime/lever/switcher_settings.cc +++ librime-1.14.0/src/rime/lever/switcher_settings.cc @@ -6,12 +6,12 @@ // #include #include -#include +#include #include #include #include -namespace fs = std::filesystem; +namespace fs = boost::filesystem; namespace rime { Index: librime-1.14.0/src/rime/lever/user_dict_manager.cc =================================================================== --- librime-1.14.0.orig/src/rime/lever/user_dict_manager.cc +++ librime-1.14.0/src/rime/lever/user_dict_manager.cc @@ -6,7 +6,7 @@ // #include #include -#include +#include #include #include #include @@ -16,7 +16,7 @@ #include #include -namespace fs = std::filesystem; +namespace fs = boost::filesystem; namespace rime { @@ -40,7 +40,7 @@ void UserDictManager::GetUserDictList(Us return; } for (fs::directory_iterator it(path_), end; it != end; ++it) { - string name = it->path().filename().u8string(); + string name = it->path().filename().string(); if (boost::ends_with(name, component->extension())) { boost::erase_last(name, component->extension()); user_dict_list->push_back(name); @@ -163,7 +163,7 @@ bool UserDictManager::UpgradeUserDict(co LOG(INFO) << "upgrading user dict '" << dict_name << "'."; path trash = deployer_->user_data_dir / "trash"; if (!fs::exists(trash)) { - std::error_code ec; + boost::system::error_code ec; if (!fs::create_directories(trash, ec)) { LOG(ERROR) << "error creating directory '" << trash << "'."; return false; @@ -180,7 +180,7 @@ bool UserDictManager::Synchronize(const bool success = true; path sync_dir(deployer_->sync_dir); if (!fs::exists(sync_dir)) { - std::error_code ec; + boost::system::error_code ec; if (!fs::create_directories(sync_dir, ec)) { LOG(ERROR) << "error creating directory '" << sync_dir << "'."; return false; Index: librime-1.14.0/src/rime/resource.cc =================================================================== --- librime-1.14.0.orig/src/rime/resource.cc +++ librime-1.14.0/src/rime/resource.cc @@ -4,13 +4,13 @@ // #include -#include +#include #include namespace rime { string ResourceResolver::ToResourceId(const string& file_path) const { - string string_path = path(file_path).generic_u8string(); + string string_path = path(file_path).generic_string(); bool has_prefix = boost::starts_with(string_path, type_.prefix); bool has_suffix = boost::ends_with(string_path, type_.suffix); size_t start = (has_prefix ? type_.prefix.length() : 0); @@ -27,16 +27,16 @@ string ResourceResolver::ToFilePath(cons } path ResourceResolver::ResolvePath(const string& resource_id) { - return std::filesystem::absolute(root_path_ / + return boost::filesystem::absolute(root_path_ / (type_.prefix + resource_id + type_.suffix)); } path FallbackResourceResolver::ResolvePath(const string& resource_id) { auto default_path = ResourceResolver::ResolvePath(resource_id); - if (!std::filesystem::exists(default_path)) { - auto fallback_path = std::filesystem::absolute( + if (!boost::filesystem::exists(default_path)) { + auto fallback_path = boost::filesystem::absolute( fallback_root_path_ / (type_.prefix + resource_id + type_.suffix)); - if (std::filesystem::exists(fallback_path)) { + if (boost::filesystem::exists(fallback_path)) { return fallback_path; } } Index: librime-1.14.0/test/resource_resolver_test.cc =================================================================== --- librime-1.14.0.orig/test/resource_resolver_test.cc +++ librime-1.14.0/test/resource_resolver_test.cc @@ -1,9 +1,9 @@ #include -#include +#include #include #include -namespace fs = std::filesystem; +namespace fs = boost::filesystem; using namespace rime; static const ResourceType kMineralsType = ResourceType{ Index: librime-1.14.0/tools/rime_table_decompiler.cc =================================================================== --- librime-1.14.0.orig/tools/rime_table_decompiler.cc +++ librime-1.14.0/tools/rime_table_decompiler.cc @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) { fout << "# Rime dictionary\n\n"; fout << "---\n" "name: " - << file_path.stem().u8string() + << file_path.stem().string() << "\n" "version: \"1.0\"\n" "...\n\n";