deleteDirectory method

  1. @override
Future<void> deleteDirectory(
  1. String path
)
override

Deletes the directory at the specified path.

Implementation

@override
Future<void> deleteDirectory(String path) async {
  if (_isDirectChildOfRoot(path)) {
    throw FileSystemException(
        "Cannot delete directory directly in the virtual root", path);
  }
  final fullPath = resolvePath(path);
  if (fullPath == rootDirectory) {
    throw FileSystemException("Cannot delete root directory", path);
  }
  final dir = Directory(fullPath);
  if (await dir.exists()) {
    await dir.delete(recursive: true);
  } else {
    throw FileSystemException(
        "Directory not found for deletion: $path (resolved to $fullPath)");
  }
}