createNewFileSync static method

Result<File, IoError> createNewFileSync(
  1. Path path
)

Creates a file at the specified path if it does not exist, and will fail if it does. The target directory must exist.

Implementation

static Result<File, IoError> createNewFileSync(Path path) {
  return Fs.ioGuardSync(() {
    final file = File(path.asString());
    file.createSync(recursive: false, exclusive: true);
    return file;
  });
}