B:BD[
3.8009] → [
3.8009:8043]
B:BD[
3.8043] → [
2.1164:1544]
∅:D[
2.1544] → [
3.8295:8340]
B:BD[
3.8295] → [
3.8295:8340]
B:BD[
3.8340] → [
2.1545:1563]
∅:D[
2.1563] → [
3.8400:8424]
B:BD[
3.8400] → [
3.8400:8424]
B:BD[
3.8424] → [
2.1564:1596]
∅:D[
2.1596] → [
3.8424:8430]
B:BD[
3.8424] → [
3.8424:8430]
B:BD[
3.8430] → [
2.1597:1602]
∅:D[
2.1602] → [
3.8472:8530]
B:BD[
3.8472] → [
3.8472:8530]
B:BD[
3.8530] → [
2.1603:3479]
∅:D[
2.3479] → [
3.9077:9095]
B:BD[
3.9077] → [
3.9077:9095]
B:BD[
3.9095] → [
2.3480:4268]
∅:D[
2.4268] → [
3.9095:9136]
B:BD[
3.9095] → [
3.9095:9136]
let mut configs = Vec::new();
let config_files = std::fs::read_dir("/usr/lib/tmpfiles.d");
match config_files {
Ok(config_list) => {
for file in config_list {
match file {
Ok(f) => match parser::parse(&f.path()) {
Ok(config) => configs.push(config),
Err(e) => return Err(e),
},
Err(e) => return Err(e),
}
}
}
Err(e) => return Err(e)
}
for config in &configs {
for line in config {
let mut mode: u32;
match line.mode.as_str() {
"0755" => mode = 0o755,
"755" => mode = 0o755,
"1755" => mode = 1755,
"0644" => mode = 0o644,
"644" => mode = 0o644,
"1644" => mode = 1644,
_ => todo!(),
}
match line.file_type.as_str() {
"f" => {
match OpenOptions::new()
.create(true)
.mode(mode) // .mode(line.mode.parse::<u32>().unwrap())
.open(&line.path.as_os_str())
{
Ok(k) => println!("Created file: {:#?}", &line.path.as_os_str()),
Err(e) => {
println!(
"Failed to create {:#?} with reason {}!",
&line.path.as_os_str(),
e
);
println!("Mode: {}", line.mode.parse::<u32>().unwrap());
return Err(e);
}
}
}
"f+" => {
match OpenOptions::new()
.create(true)
.truncate(true)
.mode(mode)
.open(&line.path.as_os_str())
{
Ok(k) => println!(
"Created file: {:#?} with truncation",
&line.path.as_os_str()
),
Err(e) => {
println!("Failed to create {:#?}!", &line.path.as_os_str());
return Err(e);
}
}
}
"d" => match build_dir(&line.path, mode) {
Ok(k) => println!(
"Created path {:#?} with mode {}",
&line.path.as_os_str(),
mode
),
Err(e) => {
println!(
"Failed to create {:#?} with mode {} with error {}!",
&line.path.as_os_str(),
mode,
e
);
return Err(e.into());
}
},
_ => eprintln!(
"ERROR: File type \"{}\" is not implemented.",
line.file_type
),
}
}
}
Ok(())
let mut configs = Vec::new();
let config_files = std::fs::read_dir("/usr/lib/tmpfiles.d");
match config_files {
Ok(config_list) => {
for file in config_list {
match file {
Ok(f) => match parser::parse(&f.path()) {
Ok(config) => configs.push(config),
Err(e) => return Err(e),
},
Err(e) => return Err(e),
}
}
}
Err(e) => return Err(e),
}
for config in &configs {
for line in config {
match line.file_type.as_str() {
"f" => {
match OpenOptions::new()
.create(true)
.append(true)
.mode(u32::from_str_radix(&line.mode, 8).unwrap())
.open(&line.path.as_os_str())
{
Ok(k) => continue,
Err(e) => {
println!(
"Failed to create {:#?} with reason {}!",
&line.path.as_os_str(),
e
);
println!("Mode: {}", &line.mode);
return Err(e);
}
}
}
"f+" => {
match OpenOptions::new()
.create(true)
.append(true)
.truncate(true)
.mode(u32::from_str_radix(&line.mode, 8).unwrap())
.open(&line.path.as_os_str())
{
Ok(k) => continue,
Err(e) => {
println!("Failed to create {:#?}!", &line.path.as_os_str());
return Err(e);
}
}
}
"w" => {
// TODO: Handle if there is a newline
if !line.argument.contains("\n") {
let mut file = std::fs::File::open(&line.path.as_os_str()).unwrap();
match file.write_all(&line.argument.as_bytes()) {
Ok(k) => continue,
Err(e) => {
println!("Failed to write to {:#?}!", &line.path.as_os_str());
return Err(e);
}
}
}
}
"w+" => {
// TODO: Handle if there is not a newline
if line.argument.contains("\n") {
let mut file = std::fs::File::open(&line.path.as_os_str()).unwrap();
match file.write_all(&line.argument.as_bytes()) {
Ok(k) => continue,
Err(e) => {
println!("Failed to write to {:#?}!", &line.path.as_os_str());
return Err(e);
}
}
}
}
"d" => match build_dir(&line.path, u32::from_str_radix(&line.mode, 8).unwrap()) {
Ok(k) => continue,
Err(e) => {
println!(
"Failed to create {:#?} with mode {} with error {}!",
&line.path.as_os_str(),
&line.mode,
e
);
return Err(e.into());
}
},
// TODO: Handle deleting directory contents
"D" => match build_dir(&line.path, u32::from_str_radix(&line.mode, 8).unwrap()) {
Ok(k) => continue,
Err(e) => {
println!(
"Failed to create {:#?} with mode {} with error {}!",
&line.path.as_os_str(),
&line.mode,
e
);
return Err(e.into());
}
},
"e" => todo!(),
"v" => todo!(),
"q" => todo!(),
"Q" => todo!(),
"p" => todo!(),
"p+" => todo!(),
"L" => todo!(),
"L+" => todo!(),
"L?" => todo!(),
"c" => todo!(),
"c+" => todo!(),
"b" => todo!(),
"b+" => todo!(),
"C" => todo!(),
"C+" => todo!(),
"x" => todo!(),
"X" => todo!(),
"r" => todo!(),
"R" => todo!(),
"z" => todo!(),
"Z" => todo!(),
"t" => todo!(),
"T" => todo!(),
"h" => todo!(),
"H" => todo!(),
"a" => todo!(),
"a+" => todo!(),
"A" => todo!(),
"A+" => todo!(),
_ => eprintln!(
"ERROR: File type \"{}\" is not implemented.",
line.file_type
),
}
}
}
Ok(())