1use std::fs;
2use std::path::PathBuf;
3
4fn main() {
5 let yaml_path = PathBuf::from("tests/fixtures/tree.yaml");
7
8 let tree = tree_fs::from_yaml_file(&yaml_path).expect("Failed to create tree from YAML file");
9
10 println!("--- Tree from YAML File Example ---");
11 println!("Tree created successfully from: {}", yaml_path.display());
12 println!("Root directory: {}", tree.root.display());
13 println!("Files created (check tests/fixtures/tree.yaml for full structure including a readonly file):");
14 println!(" - {}", tree.root.join("foo.json").display());
15 println!(" - {}", tree.root.join("folder/bar.yaml").display());
16 println!(" - {}", tree.root.join("readonly_config.ini").display());
17
18 let readonly_path = tree.root.join("readonly_config.ini");
20 if readonly_path.exists() {
21 match fs::metadata(&readonly_path) {
22 Ok(metadata) => {
23 if metadata.permissions().readonly() {
24 println!("Verified: {} is read-only.", readonly_path.display());
25 } else {
26 println!(
27 "Note: {} was expected to be read-only but isn't.",
28 readonly_path.display()
29 );
30 }
31 }
32 Err(e) => eprintln!(
33 "Could not get metadata for {}: {}",
34 readonly_path.display(),
35 e
36 ),
37 }
38 } else {
39 eprintln!("File not found: {}", readonly_path.display());
40 }
41}