moveSync static method
Moves a file or directory, possibly just a rename operation.
Implementation
static Result<(), IoError> moveSync(Path from, Path to) {
final fromStr = from.asString();
final toStr = to.asString();
return Fs.ioGuardResultSync(() {
FileSystemEntity entity = File(fromStr);
if (entity.existsSync()) {
return Ok(entity.renameSync(toStr));
}
entity = Directory(fromStr);
if (entity.existsSync()) {
return Ok(entity.renameSync(toStr));
}
entity = Link(fromStr);
if (entity.existsSync()) {
return Ok(entity.renameSync(toStr));
}
return Err(
IoError.ioException(PathNotFoundException(fromStr, const OSError())));
}).map((_) => ());
}