diff --git a/src/applib/command_executor_gui.cpp b/src/applib/command_executor_gui.cpp index 56e59b0b..722a5cec 100644 --- a/src/applib/command_executor_gui.cpp +++ b/src/applib/command_executor_gui.cpp @@ -134,7 +134,7 @@ void CommandExecutorGui::set_running_dialog_abort_mode(bool aborting) } else if (!aborting) { std::string msg = hz::string_replace_copy(get_running_msg(), "{command}", - hz::fs_path_to_string(hz::fs::u8path(this->get_command_name()).filename())); + hz::fs_path_to_string(hz::fs_path_from_string(this->get_command_name()).filename())); running_dialog_->set_message("\n " + msg + " "); // running_dialog_->set_response_sensitive(Gtk::RESPONSE_CANCEL, true); diff --git a/src/applib/smartctl_executor.cpp b/src/applib/smartctl_executor.cpp index 5d76c282..dcf2c413 100644 --- a/src/applib/smartctl_executor.cpp +++ b/src/applib/smartctl_executor.cpp @@ -22,7 +22,7 @@ License: GNU General Public License v3.0 only hz::fs::path get_smartctl_binary() { - auto smartctl_binary = hz::fs::u8path(rconfig::get_data("system/smartctl_binary")); + auto smartctl_binary = hz::fs_path_from_string(rconfig::get_data("system/smartctl_binary")); if constexpr(BuildEnv::is_kernel_family_windows()) { // Look in smartmontools installation directory. @@ -56,7 +56,7 @@ hz::fs::path get_smartctl_binary() debug_out_info("app", DBG_FUNC_MSG << "Smartmontools installation found at \"" << smt_inst_dir << "\", using \"" << smt_smartctl << "\".\n"); - auto p = hz::fs::u8path(smt_inst_dir) / hz::fs::u8path(smt_smartctl); + auto p = hz::fs_path_from_string(smt_inst_dir) / hz::fs_path_from_string(smt_smartctl); if (!hz::fs::exists(p) || !hz::fs::is_regular_file(p)) break; diff --git a/src/applib/storage_detector_linux.cpp b/src/applib/storage_detector_linux.cpp index b3a3422f..d6858974 100644 --- a/src/applib/storage_detector_linux.cpp +++ b/src/applib/storage_detector_linux.cpp @@ -61,7 +61,7 @@ inline std::string detect_drives_linux_udev_byid(std::vector& devic debug_out_info("app", DBG_FUNC_MSG << "Detecting through device scan directory /dev/disk/by-id...\n"); // this defaults to "/dev/disk/by-id" - auto dir = hz::fs::u8path(rconfig::get_data("system/linux_udev_byid_path")); + auto dir = hz::fs_path_from_string(rconfig::get_data("system/linux_udev_byid_path")); if (dir.empty()) { debug_out_warn("app", DBG_FUNC_MSG << "Device directory path is not set.\n"); return "Device directory path is not set."; @@ -177,7 +177,7 @@ inline std::error_code read_proc_file_lines(const hz::fs::path& file, std::vecto /// Read /proc/partitions file. Return error message on error. inline std::string read_proc_partitions_file(std::vector& lines) { - auto file = hz::fs::u8path(rconfig::get_data("system/linux_proc_partitions_path")); + auto file = hz::fs_path_from_string(rconfig::get_data("system/linux_proc_partitions_path")); if (file.empty()) { debug_out_warn("app", DBG_FUNC_MSG << "Partitions file path is not set.\n"); return _("Partitions file path is not set."); @@ -202,7 +202,7 @@ inline std::string read_proc_partitions_file(std::vector& lines) /// Read /proc/devices file. Return error message on error. inline std::string read_proc_devices_file(std::vector& lines) { - auto file = hz::fs::u8path(rconfig::get_data("system/linux_proc_devices_path")); + auto file = hz::fs_path_from_string(rconfig::get_data("system/linux_proc_devices_path")); if (file.empty()) { debug_out_warn("app", DBG_FUNC_MSG << "Devices file path is not set.\n"); return _("Devices file path is not set."); @@ -229,7 +229,7 @@ inline std::string read_proc_devices_file(std::vector& lines) /// Note that scsi host # is not unique. inline std::string read_proc_scsi_scsi_file(std::vector< std::pair >& vendors_models) { - auto file = hz::fs::u8path(rconfig::get_data("system/linux_proc_scsi_scsi_path")); + auto file = hz::fs_path_from_string(rconfig::get_data("system/linux_proc_scsi_scsi_path")); if (file.empty()) { debug_out_warn("app", DBG_FUNC_MSG << "SCSI file path is not set.\n"); return _("SCSI file path is not set."); @@ -276,7 +276,7 @@ inline std::string read_proc_scsi_scsi_file(std::vector< std::pair>& sg_entries) { - auto file = hz::fs::u8path(rconfig::get_data("system/linux_proc_scsi_sg_devices_path")); + auto file = hz::fs_path_from_string(rconfig::get_data("system/linux_proc_scsi_sg_devices_path")); if (file.empty()) { debug_out_warn("app", DBG_FUNC_MSG << "Sg devices file path is not set.\n"); return _("SCSI sg devices file path is not set."); @@ -815,7 +815,7 @@ inline std::string detect_drives_linux_areca(std::vector& driv int max_ports = 0; // Read the number of ports. - auto ports_file = hz::fs::u8path(hz::string_sprintf("/sys/bus/scsi/devices/host%d/scsi_host/host%d/host_fw_hd_channels", host_num, host_num)); + auto ports_file = hz::fs_path_from_string(hz::string_sprintf("/sys/bus/scsi/devices/host%d/scsi_host/host%d/host_fw_hd_channels", host_num, host_num)); std::string ports_file_contents; auto ec = read_proc_file(ports_file, ports_file_contents); if (ec) { diff --git a/src/applib/storage_detector_other.cpp b/src/applib/storage_detector_other.cpp index f8d8a125..397a9116 100644 --- a/src/applib/storage_detector_other.cpp +++ b/src/applib/storage_detector_other.cpp @@ -49,7 +49,7 @@ std::string detect_drives_other(std::vector& drives, return _("Device directory path is not set."); } - auto dir = hz::fs::u8path(dev_dir); + auto dir = hz::fs_path_from_string(dev_dir); std::error_code dummy_ec; if (!hz::fs::exists(dir, dummy_ec)) { debug_out_warn("app", DBG_FUNC_MSG << "Device directory doesn't exist.\n"); diff --git a/src/applib/storage_detector_win32.cpp b/src/applib/storage_detector_win32.cpp index 92fe8db9..85b66a12 100644 --- a/src/applib/storage_detector_win32.cpp +++ b/src/applib/storage_detector_win32.cpp @@ -561,9 +561,9 @@ inline std::string detect_drives_win32_areca(std::vector& driv hz::fs::path cli_binary; if (use_cli == 1) { - cli_binary = hz::fs::u8path(rconfig::get_data("system/areca_cli_binary")); + cli_binary = hz::fs_path_from_string(rconfig::get_data("system/areca_cli_binary")); if (!cli_binary.is_absolute() && !cli_inst_path.empty()) { - cli_binary = hz::fs::u8path(cli_inst_path) / cli_binary; + cli_binary = hz::fs_path_from_string(cli_inst_path) / cli_binary; } if (cli_binary.is_absolute() && !hz::fs::exists(cli_binary)) { use_cli = 0; diff --git a/src/applib/storage_device.cpp b/src/applib/storage_device.cpp index 96643c8d..340df38e 100644 --- a/src/applib/storage_device.cpp +++ b/src/applib/storage_device.cpp @@ -64,7 +64,7 @@ StorageDevice::StorageDevice(std::string dev_or_vfile, bool is_virtual) : is_virtual_(is_virtual) { if (is_virtual_) { - virtual_file_ = hz::fs::u8path(dev_or_vfile); + virtual_file_ = hz::fs_path_from_string(dev_or_vfile); } else { device_ = std::move(dev_or_vfile); } diff --git a/src/gsc_add_device_window.cpp b/src/gsc_add_device_window.cpp index d8efe41c..485c18ba 100644 --- a/src/gsc_add_device_window.cpp +++ b/src/gsc_add_device_window.cpp @@ -170,7 +170,7 @@ void GscAddDeviceWindow::on_device_name_browse_button_clicked() if (!entry) return; - auto path = hz::fs::u8path(std::string(entry->get_text())); + auto path = hz::fs_path_from_string(std::string(entry->get_text())); int result = 0; diff --git a/src/gsc_executor_log_window.cpp b/src/gsc_executor_log_window.cpp index 0d4a1902..7b2d5a82 100644 --- a/src/gsc_executor_log_window.cpp +++ b/src/gsc_executor_log_window.cpp @@ -249,10 +249,10 @@ void GscExecutorLogWindow::on_window_save_current_button_clicked() { hz::fs::path file; #if GTK_CHECK_VERSION(3, 20, 0) - file = hz::fs::u8path(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); + file = hz::fs_path_from_string(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); last_dir = hz::fs_path_to_string(file.parent_path()); #else - file = hz::fs::u8path(dialog.get_filename()); // in fs encoding + file = hz::fs_path_from_string(dialog.get_filename()); // in fs encoding last_dir = dialog.get_current_folder(); // save for the future #endif rconfig::set_data("gui/drive_data_open_save_dir", last_dir); @@ -367,10 +367,10 @@ void GscExecutorLogWindow::on_window_save_all_button_clicked() { hz::fs::path file; #if GTK_CHECK_VERSION(3, 20, 0) - file = hz::fs::u8path(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); + file = hz::fs_path_from_string(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); last_dir = hz::fs_path_to_string(file.parent_path()); #else - file = hz::fs::u8path(dialog.get_filename()); // in fs encoding + file = hz::fs_path_from_string(dialog.get_filename()); // in fs encoding last_dir = dialog.get_current_folder(); // save for the future #endif rconfig::set_data("gui/drive_data_open_save_dir", last_dir); diff --git a/src/gsc_info_window.cpp b/src/gsc_info_window.cpp index 60345df5..32d4ac8a 100644 --- a/src/gsc_info_window.cpp +++ b/src/gsc_info_window.cpp @@ -770,10 +770,10 @@ void GscInfoWindow::on_save_info_button_clicked() { hz::fs::path file; #if GTK_CHECK_VERSION(3, 20, 0) - file = hz::fs::u8path(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); + file = hz::fs_path_from_string(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); last_dir = hz::fs_path_to_string(file.parent_path()); #else - file = hz::fs::u8path(dialog.get_filename()); // in fs encoding + file = hz::fs_path_from_string(dialog.get_filename()); // in fs encoding last_dir = dialog.get_current_folder(); // save for the future #endif rconfig::set_data("gui/drive_data_open_save_dir", last_dir); diff --git a/src/gsc_init.cpp b/src/gsc_init.cpp index 1566fa17..274e65d4 100644 --- a/src/gsc_init.cpp +++ b/src/gsc_init.cpp @@ -100,9 +100,9 @@ namespace { // Default system-wide settings. This file is empty by default. hz::fs::path global_config_file; if constexpr(BuildEnv::is_kernel_family_windows()) { - global_config_file = hz::fs::u8path("gsmartcontrol2.conf"); // CWD, installation dir by default. + global_config_file = hz::fs_path_from_string("gsmartcontrol2.conf"); // CWD, installation dir by default. } else { - global_config_file = hz::fs::u8path(BuildEnv::package_sysconf_dir()) / "gsmartcontrol2.conf"; + global_config_file = hz::fs_path_from_string(BuildEnv::package_sysconf_dir()) / "gsmartcontrol2.conf"; } debug_out_dump("app", DBG_FUNC_MSG << "Global config file: \"" << hz::fs_path_to_string(global_config_file) << "\"\n"); @@ -459,9 +459,9 @@ bool app_init_and_loop(int& argc, char**& argv) // Add data file search paths if (is_from_source) { if constexpr(BuildEnv::debug_build()) { - hz::data_file_add_search_directory("icons", hz::fs::u8path(BuildEnv::package_top_source_dir()) / "data"); - hz::data_file_add_search_directory("ui", hz::fs::u8path(BuildEnv::package_top_source_dir()) / "src/ui"); - hz::data_file_add_search_directory("doc", hz::fs::u8path(BuildEnv::package_top_source_dir()) / "doc"); + hz::data_file_add_search_directory("icons", hz::fs_path_from_string(BuildEnv::package_top_source_dir()) / "data"); + hz::data_file_add_search_directory("ui", hz::fs_path_from_string(BuildEnv::package_top_source_dir()) / "src/ui"); + hz::data_file_add_search_directory("doc", hz::fs_path_from_string(BuildEnv::package_top_source_dir()) / "doc"); } else { // Assume the source is the parent directory (standard cmake build with the build directory as a subdirectory of source directory, // and the executables placed directly in the build directory). @@ -475,9 +475,9 @@ bool app_init_and_loop(int& argc, char**& argv) hz::data_file_add_search_directory("ui", application_dir / "ui"); hz::data_file_add_search_directory("doc", application_dir / "doc"); } else { - hz::data_file_add_search_directory("icons", hz::fs::u8path(BuildEnv::package_pkgdata_dir()) / "icons"); // /usr/share/program_name/icons - hz::data_file_add_search_directory("ui", hz::fs::u8path(BuildEnv::package_pkgdata_dir()) / "ui"); // /usr/share/program_name/ui - hz::data_file_add_search_directory("doc", hz::fs::u8path(BuildEnv::package_doc_dir())); // /usr/share/doc/[packages/]gsmartcontrol + hz::data_file_add_search_directory("icons", hz::fs_path_from_string(BuildEnv::package_pkgdata_dir()) / "icons"); // /usr/share/program_name/icons + hz::data_file_add_search_directory("ui", hz::fs_path_from_string(BuildEnv::package_pkgdata_dir()) / "ui"); // /usr/share/program_name/ui + hz::data_file_add_search_directory("doc", hz::fs_path_from_string(BuildEnv::package_doc_dir())); // /usr/share/doc/[packages/]gsmartcontrol } } diff --git a/src/gsc_main_window.cpp b/src/gsc_main_window.cpp index 2e6905b1..131bef08 100644 --- a/src/gsc_main_window.cpp +++ b/src/gsc_main_window.cpp @@ -1084,7 +1084,7 @@ void GscMainWindow::run_update_drivedb() return; } - hz::fs::path update_binary_path = hz::fs::u8path("update-smart-drivedb"); + hz::fs::path update_binary_path = hz::fs_path_from_string("update-smart-drivedb"); if (smartctl_binary.is_absolute()) { update_binary_path = smartctl_binary.parent_path() / update_binary_path; } @@ -1109,7 +1109,7 @@ bool GscMainWindow::add_device(const std::string& file, const std::string& type_ // win32 doesn't have device files, so skip the check in Windows. if constexpr(!BuildEnv::is_kernel_family_windows()) { std::error_code ec; - if (!hz::fs::exists(hz::fs::u8path(file), ec)) { + if (!hz::fs::exists(hz::fs_path_from_string(file), ec)) { gui_show_error_dialog(_("Cannot add device"), (ec.message().empty() ? Glib::ustring::compose(_("Device \"%1\" doesn't exist."), file).raw() : ec.message()), this); return false; @@ -1145,7 +1145,7 @@ bool GscMainWindow::add_virtual_drive(const std::string& file) { std::string output; const int max_size = 10*1024*1024; // 10M - auto ec = hz::fs_file_get_contents(hz::fs::u8path(file), output, max_size); + auto ec = hz::fs_file_get_contents(hz::fs_path_from_string(file), output, max_size); if (ec) { debug_out_warn("app", "Cannot open virtual drive file \"" << file << "\": " << ec.message() << "\n"); gui_show_error_dialog(_("Cannot load data file"), ec.message(), this); @@ -1361,7 +1361,7 @@ void GscMainWindow::show_load_virtual_file_chooser() rconfig::set_data("gui/drive_data_open_save_dir", last_dir); for (const auto& file : files) { std::error_code ec; - if (!hz::fs::is_directory(hz::fs::u8path(file), ec)) { // file chooser returns selected directories as well, ignore them. + if (!hz::fs::is_directory(hz::fs_path_from_string(file), ec)) { // file chooser returns selected directories as well, ignore them. this->add_virtual_drive(file); } } diff --git a/src/gsc_preferences_window.cpp b/src/gsc_preferences_window.cpp index f27db0a6..ffba6bb5 100644 --- a/src/gsc_preferences_window.cpp +++ b/src/gsc_preferences_window.cpp @@ -515,7 +515,7 @@ void GscPreferencesWindow::on_window_reset_all_button_clicked() void GscPreferencesWindow::on_smartctl_binary_browse_button_clicked() { auto* entry = this->lookup_widget("smartctl_binary_entry"); - auto path = hz::fs::u8path(std::string(entry->get_text())); + auto path = hz::fs_path_from_string(std::string(entry->get_text())); int result = 0; diff --git a/src/gsc_text_window.h b/src/gsc_text_window.h index 92cf5b0d..ae645ef5 100644 --- a/src/gsc_text_window.h +++ b/src/gsc_text_window.h @@ -213,10 +213,10 @@ class GscTextWindow : public AppBuilderWidget, Ins { hz::fs::path file; #if GTK_CHECK_VERSION(3, 20, 0) - file = hz::fs::u8path(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); + file = hz::fs_path_from_string(app_string_from_gchar(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog.get())))); last_dir = hz::fs_path_to_string(file.parent_path()); #else - file = hz::fs::u8path(dialog.get_filename()); // in fs encoding + file = hz::fs_path_from_string(dialog.get_filename()); // in fs encoding last_dir = dialog.get_current_folder(); // save for the future #endif rconfig::set_data("gui/drive_data_open_save_dir", last_dir); diff --git a/src/hz/data_file.h b/src/hz/data_file.h index 4c9c1004..3ce0ff7a 100644 --- a/src/hz/data_file.h +++ b/src/hz/data_file.h @@ -70,7 +70,7 @@ inline fs::path data_file_find(const std::string& domain, const std::string& fil if (filename.empty()) return {}; - if (fs::u8path(filename).is_absolute()) { // shouldn't happen + if (fs_path_from_string(filename).is_absolute()) { // shouldn't happen debug_out_error("app", DBG_FUNC_MSG << "Data file \"" << filename << "\" must be relative.\n"); return {}; @@ -84,7 +84,7 @@ inline fs::path data_file_find(const std::string& domain, const std::string& fil } for (const auto& dir : dirs) { - auto file_path = dir / fs::u8path(filename); + auto file_path = dir / fs_path_from_string(filename); std::error_code ec; if (fs::exists(file_path, ec)) { diff --git a/src/hz/fs.h b/src/hz/fs.h index 78660d62..99ee8e37 100644 --- a/src/hz/fs.h +++ b/src/hz/fs.h @@ -393,7 +393,7 @@ inline fs::path fs_get_home_dir() dir = win32_get_windows_directory(); // always returns something. } - return fs::u8path(dir); + return fs_path_from_string(dir); #else // linux, etc... // We use $HOME to allow the user to override it. @@ -423,7 +423,7 @@ inline fs::path fs_get_user_config_dir() #ifdef _WIN32 // that's "C:\documents and settings\username\application data". - path = fs::u8path(win32_get_special_folder(CSIDL_APPDATA)); + path = fs_path_from_string(win32_get_special_folder(CSIDL_APPDATA)); if (path.empty()) { path = fs_get_home_dir(); // fallback, always non-empty. }