openFile(forWritingAt:options:)

Open the file at path for writing.

FileSystem.swift:136
iOS
13.0+
macOS
10.15+
tvOS
13.0+
watchOS
6.0+
func openFile(forWritingAt path: FilePath, options: OpenOptions.Write) async throws -> WriteFileHandle

Parameters

path

The path of the file to open.

options

How the file should be opened.

Returns

A writable handle to the opened file.

Errors

Error codes thrown include:

  • permissionDenied if you have insufficient permissions to create the file.

  • notFound if path doesn’t exist and options weren’t set to create a file.

Implementation details

Uses the open(2) system call.