deleteDirectory method

Future<bool> deleteDirectory(
  1. String path
)

Deletes the folder at path and everything in it. Returns false when there was no folder.

Emptying a whole disk that has no prefix inside a shared OS folder, such as documents, is refused: other plugins keep files there.

Implementation

Future<bool> deleteDirectory(String path) => _run(path, () async {
  _guardWrite('deleteDirectory');
  final String target = _resolve(path);
  if (target.isEmpty && _protectRoot) {
    throw DiskException(
      'Refusing to empty this disk: it is a folder other plugins also '
      'write to. Delete the paths you own instead',
      path: path,
    );
  }
  final bool deleted = await driver.deleteDirectory(target);
  DiskImage.evictDirectory(name, stripDiskPrefix(_home, target));
  return deleted;
});