Skip to content

Instantly share code, notes, and snippets.

@devth
Last active July 18, 2016 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devth/3421a5d6eef2fbcd613c2f36bbac69e4 to your computer and use it in GitHub Desktop.
Save devth/3421a5d6eef2fbcd613c2f36bbac69e4 to your computer and use it in GitHub Desktop.
use std::fs;
use std::io;
use std::path::PathBuf;
fn main() {
let dir = env!("DIR").to_string();
println!("Looking in {}", dir);
let _ = loop_dir_contents(&dir);
}
fn loop_dir_contents(dir: &String) -> io::Result<()> {
for entry in try!(fs::read_dir(dir)) {
let app = try!(entry);
if app.path().is_dir() {
let _ = create_config_map(dir, app.path());
}
}
Ok(())
}
fn create_config_map(root: &String, app_path: PathBuf) -> io::Result<()> {
match app_path.file_name() {
Some(app_os_str) => {
let app = app_os_str.to_str().unwrap();
println!("Create ConfigMap for {}/{}", root, app);
for entry in try!(fs::read_dir(format!("{}/{}", root, app))) {
let file = try!(entry);
println!("{:?}", file.path());
}
}
None => {
println!("No path for {} {:?}", root, app_path);
}
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment