diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a03ed96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/testing_grounds diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1122634 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "mgen" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..cf61e08 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "mgen" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..1b2547a --- /dev/null +++ b/src/main.rs @@ -0,0 +1,35 @@ +use std::io; + +fn recurse_through_c_files(dir: &str) -> io::Result<()> { + let dir = std::fs::read_dir(dir)?; + + for file in dir { + let file = file?; + + let file_path = file.path(); + + if file.path().is_dir() { + recurse_through_c_files(file_path.to_str() + .expect("filepath should be converted to string slice"))?; + } + + let ext = file_path.extension() + .and_then(|v| v.to_str()) + .unwrap_or_else(|| ""); + + if ext != "c" { + continue; + } + + println!("{:?}", file.path().with_extension("o").file_name().expect("files should have names")); + todo!() + } + + Ok(()) +} + +fn main() { + recurse_through_c_files(".").unwrap_or_else(|e| { + panic!("error: could not recurse through directory: {e}"); + }); +}