chore: move file_utils and hash modules to util folder

This commit is contained in:
Gabriele Musco 2024-09-01 19:47:39 +02:00
commit 0a59954f62
23 changed files with 25 additions and 22 deletions

View file

@ -1,9 +1,9 @@
use crate::{ use crate::{
build_tools::{cmake::Cmake, git::Git}, build_tools::{cmake::Cmake, git::Git},
file_utils::rm_rf,
profile::Profile, profile::Profile,
termcolor::TermColor, termcolor::TermColor,
ui::job_worker::job::WorkerJob, ui::job_worker::job::WorkerJob,
util::file_utils::rm_rf,
}; };
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};

View file

@ -1,9 +1,9 @@
use crate::{ use crate::{
build_tools::{cmake::Cmake, git::Git}, build_tools::{cmake::Cmake, git::Git},
file_utils::rm_rf,
profile::Profile, profile::Profile,
termcolor::TermColor, termcolor::TermColor,
ui::job_worker::job::WorkerJob, ui::job_worker::job::WorkerJob,
util::file_utils::rm_rf,
}; };
use std::{ use std::{
collections::{HashMap, VecDeque}, collections::{HashMap, VecDeque},

View file

@ -1,9 +1,9 @@
use crate::{ use crate::{
build_tools::{cmake::Cmake, git::Git}, build_tools::{cmake::Cmake, git::Git},
file_utils::rm_rf,
profile::Profile, profile::Profile,
termcolor::TermColor, termcolor::TermColor,
ui::job_worker::job::WorkerJob, ui::job_worker::job::WorkerJob,
util::file_utils::rm_rf,
}; };
use std::{ use std::{
collections::{HashMap, VecDeque}, collections::{HashMap, VecDeque},

View file

@ -1,9 +1,9 @@
use crate::{ use crate::{
build_tools::{cmake::Cmake, git::Git}, build_tools::{cmake::Cmake, git::Git},
file_utils::rm_rf,
profile::Profile, profile::Profile,
termcolor::TermColor, termcolor::TermColor,
ui::job_worker::job::WorkerJob, ui::job_worker::job::WorkerJob,
util::file_utils::rm_rf,
}; };
use std::{ use std::{
collections::{HashMap, VecDeque}, collections::{HashMap, VecDeque},

View file

@ -1,9 +1,9 @@
use crate::{ use crate::{
build_tools::{cmake::Cmake, git::Git}, build_tools::{cmake::Cmake, git::Git},
file_utils::rm_rf,
profile::Profile, profile::Profile,
termcolor::TermColor, termcolor::TermColor,
ui::job_worker::job::WorkerJob, ui::job_worker::job::WorkerJob,
util::file_utils::rm_rf,
}; };
use std::{ use std::{
collections::{HashMap, VecDeque}, collections::{HashMap, VecDeque},

View file

@ -1,9 +1,9 @@
use crate::{ use crate::{
build_tools::{cmake::Cmake, git::Git}, build_tools::{cmake::Cmake, git::Git},
file_utils::rm_rf,
profile::Profile, profile::Profile,
termcolor::TermColor, termcolor::TermColor,
ui::job_worker::job::WorkerJob, ui::job_worker::job::WorkerJob,
util::file_utils::rm_rf,
}; };
use std::{ use std::{
collections::{HashMap, VecDeque}, collections::{HashMap, VecDeque},

View file

@ -1,7 +1,7 @@
use crate::{ use crate::{
file_utils::get_writer,
profile::{Profile, XRServiceType}, profile::{Profile, XRServiceType},
runner::{Runner, RunnerStatus}, runner::{Runner, RunnerStatus},
util::file_utils::get_writer,
}; };
use nix::{ use nix::{
sys::signal::{ sys::signal::{

View file

@ -1,13 +1,13 @@
use crate::{ use crate::{
constants::CMD_NAME, constants::CMD_NAME,
device_prober::PhysicalXRDevice, device_prober::PhysicalXRDevice,
file_utils::get_writer,
paths::get_config_dir, paths::get_config_dir,
profile::Profile, profile::Profile,
profiles::{ profiles::{
lighthouse::lighthouse_profile, openhmd::openhmd_profile, simulated::simulated_profile, lighthouse::lighthouse_profile, openhmd::openhmd_profile, simulated::simulated_profile,
survive::survive_profile, wivrn::wivrn_profile, wmr::wmr_profile, survive::survive_profile, wivrn::wivrn_profile, wmr::wmr_profile,
}, },
util::file_utils::get_writer,
}; };
use serde::{de::Error, Deserialize, Serialize}; use serde::{de::Error, Deserialize, Serialize};
use std::{ use std::{

View file

@ -1,4 +1,6 @@
use crate::{constants::APP_ID, file_utils::get_writer, hash::sha256, paths::get_cache_dir}; use crate::{
constants::APP_ID, paths::get_cache_dir, util::file_utils::get_writer, util::hash::sha256,
};
use reqwest::{ use reqwest::{
header::{HeaderMap, USER_AGENT}, header::{HeaderMap, USER_AGENT},
Method, Method,

View file

@ -1,7 +1,7 @@
use crate::{ use crate::{
file_utils::{copy_file, deserialize_file, get_writer, set_file_readonly},
paths::{get_backup_dir, SYSTEM_PREFIX}, paths::{get_backup_dir, SYSTEM_PREFIX},
profile::Profile, profile::Profile,
util::file_utils::{copy_file, deserialize_file, get_writer, set_file_readonly},
xdg::XDG, xdg::XDG,
}; };
use serde::{ser::Error, Deserialize, Serialize}; use serde::{ser::Error, Deserialize, Serialize};

View file

@ -1,7 +1,7 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use crate::{ use crate::{
file_utils::{deserialize_file, get_writer}, util::file_utils::{deserialize_file, get_writer},
xdg::XDG, xdg::XDG,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View file

@ -1,9 +1,9 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use crate::{ use crate::{
file_utils::{copy_file, deserialize_file, get_writer, set_file_readonly},
paths::get_backup_dir, paths::get_backup_dir,
profile::Profile, profile::Profile,
util::file_utils::{copy_file, deserialize_file, get_writer, set_file_readonly},
xdg::XDG, xdg::XDG,
}; };
use serde::{ser::Error, Deserialize, Serialize}; use serde::{ser::Error, Deserialize, Serialize};

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
file_utils::{deserialize_file, get_writer}, util::file_utils::{deserialize_file, get_writer},
xdg::XDG, xdg::XDG,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View file

@ -1,4 +1,4 @@
use crate::file_utils::get_reader; use crate::util::file_utils::get_reader;
use std::{ use std::{
error::Error, error::Error,
fmt::Display, fmt::Display,

View file

@ -1,4 +1,4 @@
use crate::file_utils::get_reader; use crate::util::file_utils::get_reader;
use std::{ use std::{
fmt::Display, fmt::Display,
io::{BufRead, Read}, io::{BufRead, Read},

View file

@ -29,9 +29,7 @@ pub mod device_prober;
pub mod downloader; pub mod downloader;
pub mod env_var_descriptions; pub mod env_var_descriptions;
pub mod file_builders; pub mod file_builders;
pub mod file_utils;
pub mod gpu_profile; pub mod gpu_profile;
pub mod hash;
pub mod is_appimage; pub mod is_appimage;
pub mod linux_distro; pub mod linux_distro;
pub mod log_level; pub mod log_level;
@ -45,6 +43,7 @@ pub mod steam_linux_runtime_injector;
pub mod steamvr_utils; pub mod steamvr_utils;
pub mod termcolor; pub mod termcolor;
pub mod ui; pub mod ui;
pub mod util;
pub mod vulkaninfo; pub mod vulkaninfo;
pub mod xdg; pub mod xdg;
pub mod xr_devices; pub mod xr_devices;

View file

@ -1,6 +1,6 @@
use crate::{ use crate::{
file_utils::get_writer,
paths::{get_data_dir, BWRAP_SYSTEM_PREFIX, SYSTEM_PREFIX}, paths::{get_data_dir, BWRAP_SYSTEM_PREFIX, SYSTEM_PREFIX},
util::file_utils::get_writer,
xdg::XDG, xdg::XDG,
}; };
use nix::NixPath; use nix::NixPath;

View file

@ -1,7 +1,7 @@
use crate::{ use crate::{
file_utils::{copy_file, get_writer},
paths::{get_backup_dir, get_home_dir}, paths::{get_backup_dir, get_home_dir},
profile::Profile, profile::Profile,
util::file_utils::{copy_file, get_writer},
}; };
use anyhow::bail; use anyhow::bail;
use std::{ use std::{

View file

@ -37,7 +37,6 @@ use crate::{
set_current_openvrpaths_to_profile, set_current_openvrpaths_to_steam, set_current_openvrpaths_to_profile, set_current_openvrpaths_to_steam,
}, },
}, },
file_utils::{setcap_cap_sys_nice_eip, setcap_cap_sys_nice_eip_cmd},
is_appimage::IS_APPIMAGE, is_appimage::IS_APPIMAGE,
linux_distro::LinuxDistro, linux_distro::LinuxDistro,
openxr_prober::is_openxr_ready, openxr_prober::is_openxr_ready,
@ -47,6 +46,7 @@ use crate::{
steam_linux_runtime_injector::{ steam_linux_runtime_injector::{
restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile, restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile,
}, },
util::file_utils::{setcap_cap_sys_nice_eip, setcap_cap_sys_nice_eip_cmd},
xr_devices::XRDevice, xr_devices::XRDevice,
}; };
use adw::{prelude::*, ResponseAppearance}; use adw::{prelude::*, ResponseAppearance};

View file

@ -14,12 +14,12 @@ use super::{
use crate::{ use crate::{
config::Config, config::Config,
dependencies::common::dep_pkexec, dependencies::common::dep_pkexec,
file_utils::{get_writer, mount_has_nosuid},
gpu_profile::{get_amd_gpu_power_profile, GpuPowerProfile}, gpu_profile::{get_amd_gpu_power_profile, GpuPowerProfile},
paths::{get_data_dir, get_home_dir}, paths::{get_data_dir, get_home_dir},
profile::{LighthouseDriver, Profile, XRServiceType}, profile::{LighthouseDriver, Profile, XRServiceType},
stateless_action, stateless_action,
steamvr_utils::chaperone_info_exists, steamvr_utils::chaperone_info_exists,
util::file_utils::{get_writer, mount_has_nosuid},
xr_devices::XRDevice, xr_devices::XRDevice,
}; };
use adw::{prelude::*, ResponseAppearance}; use adw::{prelude::*, ResponseAppearance};

View file

@ -114,7 +114,7 @@ pub fn mount_has_nosuid(path: &Path) -> Result<bool, Errno> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::file_utils::mount_has_nosuid; use super::mount_has_nosuid;
use std::path::Path; use std::path::Path;
#[test] #[test]

2
src/util/mod.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod file_utils;
pub mod hash;