mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
mv: refactor try! to ?
This commit is contained in:
parent
fb1d844e14
commit
52c7f0aa34
1 changed files with 4 additions and 4 deletions
|
@ -358,11 +358,11 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {
|
|||
BackupMode::ExistingBackup => Some(existing_backup_path(to, &b.suffix)),
|
||||
};
|
||||
if let Some(ref p) = backup_path {
|
||||
try!(fs::rename(to, p));
|
||||
fs::rename(to, p)?;
|
||||
}
|
||||
|
||||
if b.update {
|
||||
if try!(try!(fs::metadata(from)).modified()) <= try!(try!(fs::metadata(to)).modified())
|
||||
if fs::metadata(from)?.modified()? <= fs::metadata(to)?.modified()?
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -374,14 +374,14 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {
|
|||
// normalize behavior between *nix and windows
|
||||
if from.is_dir() {
|
||||
if is_empty_dir(to) {
|
||||
try!(fs::remove_dir(to))
|
||||
fs::remove_dir(to)?
|
||||
} else {
|
||||
return Err(std::io::Error::new(std::io::ErrorKind::Other, "Directory not empty"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try!(fs::rename(from, to));
|
||||
fs::rename(from, to)?;
|
||||
|
||||
if b.verbose {
|
||||
print!("‘{}’ -> ‘{}’", from.display(), to.display());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue