moveDir function
Implementation
Future<void> moveDir(String from, String to) async {
if (!exists(from)) {
StatusHelper.failed('The [from] path ${truepath(from)} does not exists.');
}
if (!isDirectory(from)) {
StatusHelper.failed(
'The [from] path ${truepath(from)} must be a directory.');
}
if (exists(to)) {
StatusHelper.failed('The [to] path ${truepath(to)} must NOT exist.');
}
try {
Directory(from).renameSync(to);
} on FileSystemException catch (_) {
copyTree(from, to, includeHidden: true);
delete(from);
}
// ignore: avoid_catches_without_on_clauses
catch (e) {
StatusHelper.failed(
'The Move of ${truepath(from)} to ${truepath(to)} failed. Error $e');
}
}