createDirectory method
Creates a directory at the specified path.
Implementation
@override
Future<void> createDirectory(String path) async {
if (_isDirectChildOfRoot(path)) {
throw FileSystemException(
"Cannot create directory directly in the virtual root", path);
}
try {
final fullPath = resolvePath(path);
if (fullPath == rootDirectory) {
throw FileSystemException("Cannot create root directory", path);
}
final dir = Directory(fullPath);
if (!await dir.exists()) {
await dir.create(recursive: true);
} else {
// Optional: Decide if this should be an error or silently succeed
// throw FileSystemException("Directory already exists: '$path' (resolved to '$fullPath')", path);
}
} catch (e) {
if (e is FileSystemException) {
rethrow;
}
throw FileSystemException(
"Failed to create directory '$path': ${e.toString()}", path);
}
}