createFile static method
Creates a file at the specified path if it does not exist, and will truncate it if it does. The target directory must exist.
Implementation
static FutureResult<File, IoError> createFile(Path path) {
return Fs.ioGuard(() async {
final file = File(path.asString());
if (await file.exists()) {
await file.writeAsBytes([]);
return file;
} else {
return file.create(recursive: false, exclusive: false);
}
});
}