mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
CRLF->LF handing in file comparisons
This commit is contained in:
parent
86cc7de6b1
commit
3b9041d8d7
1 changed files with 22 additions and 9 deletions
|
|
@ -232,7 +232,20 @@ fn compare_files(a: &Path, b: &Path) -> Result<bool, DynError> {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use buf readers since they are much faster
|
let s1 = fs::read_to_string(a);
|
||||||
|
let s2 = fs::read_to_string(b);
|
||||||
|
|
||||||
|
if s1.is_ok() && s2.is_ok() {
|
||||||
|
// text do CRLF substitutions
|
||||||
|
let f1 = s1?.replace("\r\n", "\n");
|
||||||
|
let f2 = s2?.replace("\r\n", "\n");
|
||||||
|
if f1 == f2 {
|
||||||
|
Ok(true)
|
||||||
|
} else {
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// do a binary compare
|
||||||
let f1 = BufReader::new(f1);
|
let f1 = BufReader::new(f1);
|
||||||
let f2 = BufReader::new(f2);
|
let f2 = BufReader::new(f2);
|
||||||
|
|
||||||
|
|
@ -242,6 +255,6 @@ fn compare_files(a: &Path, b: &Path) -> Result<bool, DynError> {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(true)
|
||||||
return Ok(true);
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue