Compare commits

..

2 Commits

Author SHA1 Message Date
ac0aa99ba8 add: implement basic server 2025-03-30 00:09:49 -07:00
99dc71ca40 add: rewriter logic and tests 2025-03-29 23:03:54 -07:00

View File

@@ -51,12 +51,14 @@ impl Rewriter {
// Create the directory, then carry on. Note that we explore the
// src_path after creating dst_path.
fs::create_dir(&dst_path)?;
println!("mkdir {:?}", dst_path);
to_visit.push(src_path.into_os_string().into_string().unwrap());
continue;
}
// Open 2 files; one to read and translate, and one to write.
let source_file = File::open(&src_path)?;
println!("touch {:?}", dst_path);
let mut dest_file = File::create(&dst_path)?;
let reader = BufReader::new(source_file);
@@ -65,6 +67,7 @@ impl Rewriter {
// If the line is not subject to replacement, copy it and
// carry on.
if !line.contains(&self.source) {
println!("{}", line);
writeln!(dest_file, "{}", line)?;
continue;
}
@@ -73,6 +76,7 @@ impl Rewriter {
// in question
for replacement in &replacements {
let new_line = line.replace(&self.source, &replacement);
println!("{}", new_line);
writeln!(dest_file, "{}", new_line)?;
}
}