Use same path for saving files as for loading
This commit is contained in:
parent
a4a6726091
commit
80666c2cf5
1 changed files with 8 additions and 8 deletions
16
src/files.rs
16
src/files.rs
|
|
@ -267,21 +267,21 @@ impl Files {
|
||||||
pub fn save(&self) -> Result<()> {
|
pub fn save(&self) -> Result<()> {
|
||||||
for file in &self.files {
|
for file in &self.files {
|
||||||
if file.dirty {
|
if file.dirty {
|
||||||
Self::save_file(&file.path, &file.file)?;
|
Self::save_file(file)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_file(path: &Path, file: &File) -> Result<()> {
|
fn save_file(file: &LoadedFile) -> Result<()> {
|
||||||
// TODO Sort commands within file
|
// TODO Sort commands within file
|
||||||
let formatted = format!("{}", file);
|
let formatted = format!("{}", file.file);
|
||||||
if file.contents == formatted {
|
if file.file.contents == formatted {
|
||||||
println!("Unchanged file {:?}", path);
|
println!("Unchanged file {:?}", file.name);
|
||||||
} else {
|
} else {
|
||||||
println!("Saving file {:?}", path);
|
println!("Saving file {:?}", file.name);
|
||||||
fs::write(path, &formatted).map_err(|e| Error::WriteFile {
|
fs::write(&file.name, &formatted).map_err(|e| Error::WriteFile {
|
||||||
file: path.to_path_buf(),
|
file: file.name.to_path_buf(),
|
||||||
error: e,
|
error: e,
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue