In timezones stage changing get_timezones_blocking from using systemd timedatectl to query filesystem directly.

This commit is contained in:
kira committed 2026-11-03 08:38:51 +01:00
1 parent 6f921f3ff0
commit fb90bc3092
2 files changed
+63 -3

No files matched your search

+46
View File
@@ -20,7 +20,9 @@
use crate::kira_disk_layout::*;
use crate::kira_size::KiraSize;
use std::fmt::format;
use std::fs;
use std::path::Path;
use std::process::Command;
#[derive(Debug)]
@@ -330,3 +332,47 @@ pub fn mkswap(dev: &str) -> Result<(), ExecCommandError> {
//mkswap -L SWAP /dev/sda4
exec_command("mkswap", &vec!["-L", "bee-swap", dev])
}
///
/// Returns list of files in directory and all subdirectories
/// Files in subdirectories listed with path related to specified dir
/// for example subdir1/subdir2/file
///
pub fn ls_dir_rec(dir_part: &Path) -> Result<Vec<String>, std::io::Error> {
fn ls_subdir_rec(root_path: &Path, prefix: String, mut res: Vec<String>) -> Result<Vec<String>, std::io::Error> {
if root_path.is_dir() {
for dir_entry in fs::read_dir(root_path)? {
let dir_entry = dir_entry?;
let dir_entry_path = dir_entry.path();
let next_prefix = format!("{}/{}", prefix, dir_entry.file_name().to_string_lossy());
if dir_entry_path.is_dir() {
res = ls_subdir_rec(&dir_entry_path, next_prefix, res)?;
}
else {
res.push(next_prefix);
}
}
}
Ok(res)
}
let mut res: Vec<String> = Vec::new();
//let loc_path: &Path = Path::new("/usr/share/zoneinfo");
if dir_part.is_dir() {
for d_entry in fs::read_dir(dir_part)? {
let d_entry = d_entry?;
let d_entry_path = d_entry.path();
let d_entry_name = d_entry.file_name().to_string_lossy().to_string();
if d_entry_path.is_dir() {
res = ls_subdir_rec(&d_entry_path, d_entry_name, res)?;
} else {
// Add file to list
res.push(d_entry_name);
}
}
}
Ok(res)
}