createNewFile static method

FutureResult<File, IoError> createNewFile(
  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 FutureResult<File, IoError> createNewFile(Path path) {
  return Fs.ioGuard(() async {
    final file = File(path.asString());
    return file.create(recursive: false, exclusive: true);
  });
}