mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-26 05:45:35 +00:00
Ported away from deprecated u8path().
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Copyright:
|
||||
|
||||
hz::fs::path get_smartctl_binary()
|
||||
{
|
||||
auto smartctl_binary = hz::fs::u8path(rconfig::get_data<std::string>("system/smartctl_binary"));
|
||||
auto smartctl_binary = hz::fs_path_from_string(rconfig::get_data<std::string>("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;
|
||||
|
||||
@@ -61,7 +61,7 @@ inline std::string detect_drives_linux_udev_byid(std::vector<std::string>& 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<std::string>("system/linux_udev_byid_path"));
|
||||
auto dir = hz::fs_path_from_string(rconfig::get_data<std::string>("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<std::string>& lines)
|
||||
{
|
||||
auto file = hz::fs::u8path(rconfig::get_data<std::string>("system/linux_proc_partitions_path"));
|
||||
auto file = hz::fs_path_from_string(rconfig::get_data<std::string>("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<std::string>& lines)
|
||||
/// Read /proc/devices file. Return error message on error.
|
||||
inline std::string read_proc_devices_file(std::vector<std::string>& lines)
|
||||
{
|
||||
auto file = hz::fs::u8path(rconfig::get_data<std::string>("system/linux_proc_devices_path"));
|
||||
auto file = hz::fs_path_from_string(rconfig::get_data<std::string>("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<std::string>& lines)
|
||||
/// Note that scsi host # is not unique.
|
||||
inline std::string read_proc_scsi_scsi_file(std::vector< std::pair<int, std::string> >& vendors_models)
|
||||
{
|
||||
auto file = hz::fs::u8path(rconfig::get_data<std::string>("system/linux_proc_scsi_scsi_path"));
|
||||
auto file = hz::fs_path_from_string(rconfig::get_data<std::string>("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<int, std::str
|
||||
/// Each line index corresponds to N in /dev/sgN.
|
||||
inline std::string read_proc_scsi_sg_devices_file(std::vector<std::vector<int>>& sg_entries)
|
||||
{
|
||||
auto file = hz::fs::u8path(rconfig::get_data<std::string>("system/linux_proc_scsi_sg_devices_path"));
|
||||
auto file = hz::fs_path_from_string(rconfig::get_data<std::string>("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<StorageDevicePtr>& 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) {
|
||||
|
||||
@@ -49,7 +49,7 @@ std::string detect_drives_other(std::vector<StorageDevicePtr>& 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");
|
||||
|
||||
@@ -561,9 +561,9 @@ inline std::string detect_drives_win32_areca(std::vector<StorageDevicePtr>& driv
|
||||
|
||||
hz::fs::path cli_binary;
|
||||
if (use_cli == 1) {
|
||||
cli_binary = hz::fs::u8path(rconfig::get_data<std::string>("system/areca_cli_binary"));
|
||||
cli_binary = hz::fs_path_from_string(rconfig::get_data<std::string>("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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+8
-8
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Gtk::Entry*>("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;
|
||||
|
||||
|
||||
@@ -213,10 +213,10 @@ class GscTextWindow : public AppBuilderWidget<GscTextWindow<InstanceSwitch>, 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);
|
||||
|
||||
+2
-2
@@ -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)) {
|
||||
|
||||
+2
-2
@@ -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.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user