Skip to content

Commit d7aeb31

Browse files
committed
Debug paths
1 parent a50a2a2 commit d7aeb31

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

doc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ repository = "https://github.com/fschutt/azul"
1111
readme = "../README.md"
1212
edition = "2021"
1313
publish = false
14+
build = "build.rs"
1415

1516
[dependencies]
1617
serde = { version = "1", default-features = false }

doc/build.rs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use std::fs;
2+
use std::io;
3+
use std::path::Path;
4+
5+
fn list_dir_contents<P: AsRef<Path>>(path: P, depth: usize) -> io::Result<()> {
6+
let path = path.as_ref();
7+
8+
if !path.is_dir() {
9+
return Ok(());
10+
}
11+
12+
fs::read_dir(path)?
13+
.filter_map(Result::ok)
14+
.try_for_each(|entry| {
15+
let path = entry.path();
16+
let name = path.file_name()
17+
.map_or_else(|| "".to_string(), |n| n.to_string_lossy().into());
18+
19+
println!("{}{}", "\t".repeat(depth), name);
20+
21+
if path.is_dir() {
22+
list_dir_contents(&path, depth + 1)?;
23+
}
24+
25+
Ok(()) as io::Result<()>
26+
})
27+
}
28+
29+
fn print_dir_tree<P: AsRef<Path>>(dir: P) -> io::Result<()> {
30+
let path = dir.as_ref();
31+
32+
if !path.exists() {
33+
return Err(io::Error::new(io::ErrorKind::NotFound, "Path not found"));
34+
}
35+
36+
println!("{}", path.display());
37+
38+
if path.is_dir() {
39+
list_dir_contents(path, 1)
40+
} else {
41+
Ok(())
42+
}
43+
}
44+
45+
fn main() -> io::Result<()> {
46+
print_dir_tree(".")?;
47+
Ok(())
48+
}

0 commit comments

Comments
 (0)