init_dir/lib.rs
1pub fn ignore(cache: &std::path::Path) -> Result<(), std::io::Error> {
2 if let Ok(meta) = std::fs::metadata(cache) {
3 if meta.is_dir() {
4 return Ok(());
5 }
6 std::fs::remove_file(cache)?;
7 }
8 std::fs::create_dir_all(cache)?;
9 use std::io::Write;
10
11 ifs::w(cache.join(".gitignore"))?.write_all(
12 r#"**/*
13!**/.gitignore"#
14 .to_string()
15 .as_bytes(),
16 )?;
17 Ok(())
18}