renameSync method

  1. @override
Directory renameSync(
  1. String newPath
)
override

Synchronously renames this file system entity.

Returns a FileSystemEntity instance for the renamed entity.

Implementation

@override
Directory renameSync(String newPath) {
  final dir = assertDirectoryIsEmpty(_fs, path, 'Rename failed');

  final newDir = MemoryDirectory._(_fs, newPath);
  newDir.createSync();

  _fs.remove(path); // Remove the old directory.
  _fs.set(newPath, dir);

  return MemoryDirectory._(_fs, newPath);
}