createDirectory method
Creates a directory at path.
With recursive, missing parent directories are created and an
existing directory is accepted. Without it, the parent must exist and
an existing directory throws.
Implementation
@override
Future<void> createDirectory(String path, {bool recursive = false}) async {
final String normalized = _normalize(path);
if (_files.containsKey(normalized)) {
throw StateError('a file already sits at "$path"');
}
if (_directories.contains(normalized)) {
if (!recursive) {
throw StateError('directory "$path" already exists');
}
return;
}
if (!recursive && !_directories.contains(_parentOf(normalized))) {
throw StateError('no parent directory of "$path"');
}
_seedAncestorsOf(normalized);
_directories.add(normalized);
}