createDirectory method

void createDirectory(
  1. String path
)

Creates path and records every directory this call had to create.

Empty created directories are removed after file restoration. Directories that acquire user or application files while the patch is active remain.

Implementation

void createDirectory(String path) {
  final requested = Directory(path).absolute;
  if (requested.existsSync()) return;

  final missing = <String>[];
  var ancestor = requested;
  while (!ancestor.existsSync()) {
    missing.add(ancestor.path);
    final parent = ancestor.parent;
    if (parent.path == ancestor.path) break;
    ancestor = parent;
  }
  requested.createSync(recursive: true);
  _createdDirectories.addAll(missing);
}