move method
Rename or move oldPath to newPath
If sudo is true, the file will be moved with sudo permissions
Implementation
Future<bool> move(
String $oldPath,
String $newPath, {
sudo = false,
force = false,
recursive = false,
preserve = false,
}) async {
try {
if (Platform.isWindows) {
await File($oldPath).rename($newPath);
return true;
} else {
List<String> args = [$oldPath, $newPath];
if (recursive) {
args.insert(0, '-r');
}
if (force) {
args.insert(0, '-f');
}
if (preserve) {
args.insert(0, '-p');
}
final result = await simple('mv', args, sudo: sudo);
return result.exitCode == 0;
}
} catch (e) {
return false;
}
}