renameFileSync method

  1. @override
void renameFileSync(
  1. String oldPath,
  2. String newPath
)
override

Renames/moves a file from one path to another synchronously.

Throws an Exception if oldPath doesn't exist.

Implementation

@override
void renameFileSync(String oldPath, String newPath) {
  final fullOldPath = _resolvePath(oldPath);
  final fullNewPath = _resolvePath(newPath);
  final file = File(fullOldPath);
  if (!file.existsSync()) {
    throw Exception('File does not exist: $oldPath');
  }
  File(fullNewPath).parent.createSync(recursive: true);
  file.renameSync(fullNewPath);
}