remove method
Removes a file or directory. With force, a missing path is not an
error.
Implementation
@override
Future<Result<void, FileError>> remove(
String path, {
bool recursive = false,
bool force = false,
}) async {
final resolved = _normalize(path);
final isFile = _files.containsKey(resolved);
final isDir = _dirs.contains(resolved);
if (!isFile && !isDir) {
if (force) return const Ok(null);
return Err(
FileError(
FileErrorCode.notFound,
'No such file or directory',
path: resolved,
),
);
}
if (isFile) {
_files.remove(resolved);
return const Ok(null);
}
return _removeDir(resolved, recursive: recursive);
}