Structureswift-system 1.3.2SystemPackage
OpenOptions
Options that specify behavior for a newly-opened file.
FileDescriptor.swift:89@frozen struct OpenOptions
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (21) members.
Types
struct AccessMode
The desired read and write access for a newly opened file.
struct SeekOrigin
Options for specifying what a file descriptor’s offset is relative to.
Type members
init(rawValue: CInt
) Creates a strongly-typed file handle from a raw C file handle.
static var standardError: FileDescriptor
The standard error file descriptor, with a numeric value of 2.
static var standardInput: FileDescriptor
The standard input file descriptor, with a numeric value of 0.
static var standardOutput: FileDescriptor
The standard output file descriptor, with a numeric value of 1.
static func open(UnsafePointer<CInterop.PlatformChar>, FileDescriptor.AccessMode, options: FileDescriptor.OpenOptions, permissions: FilePermissions?, retryOnInterrupt: Bool
) throws -> FileDescriptor Opens or creates a file for reading or writing.
static func open(FilePath, FileDescriptor.AccessMode, options: FileDescriptor.OpenOptions, permissions: FilePermissions?, retryOnInterrupt: Bool
) throws -> FileDescriptor Opens or creates a file for reading or writing.
static func pipe(
) throws -> (readEnd: FileDescriptor, writeEnd: FileDescriptor) Create a pipe, a unidirectional data channel which can be used for interprocess communication.
Instance members
let rawValue: CInt
The raw C file handle.
func close(
) throws Deletes a file descriptor.
func closeAfter<R>(() throws -> R
) throws -> R Runs a closure and then closes the file descriptor, even if an error occurs.
func duplicate(as: FileDescriptor?, retryOnInterrupt: Bool
) throws -> FileDescriptor Duplicate this file descriptor and return the newly created copy.
func read(fromAbsoluteOffset: Int64, into: UnsafeMutableRawBufferPointer, retryOnInterrupt: Bool
) throws -> Int Reads bytes at the specified offset into a buffer.
func read(into: UnsafeMutableRawBufferPointer, retryOnInterrupt: Bool
) throws -> Int Reads bytes at the current file offset into a buffer.
func resize(to: Int64, retryOnInterrupt: Bool
) throws Truncate or extend the file referenced by this file descriptor.
func seek(offset: Int64, from: FileDescriptor.SeekOrigin
) throws -> Int64 Reposition the offset for the given file descriptor.
func write(UnsafeRawBufferPointer, retryOnInterrupt: Bool
) throws -> Int Writes the contents of a buffer at the current file offset.
func write(toAbsoluteOffset: Int64, UnsafeRawBufferPointer, retryOnInterrupt: Bool
) throws -> Int Writes the contents of a buffer at the specified offset.
func writeAll<S>(S
) throws -> Int Writes a sequence of bytes to the current offset and then updates the offset.
func writeAll<S>(toAbsoluteOffset: Int64, S
) throws -> Int Writes a sequence of bytes to the given offset.
Citizens in SystemPackage
Conformances
protocol BitwiseCopyable
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol ExpressibleByArrayLiteral
A type that can be initialized using an array literal.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol OptionSet
A type that presents a mathematical set interface to a bit set.
protocol RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
protocol Sendable
protocol SetAlgebra<Element>
A type that provides mathematical set operations.
Type members
init(rawValue: CInt
) Create a strongly-typed options value from raw C options.
static var append: OpenOptions
Indicates that each write operation appends to the file.
static var closeOnExec: OpenOptions
Indicates that executing a program closes the file.
static var create: OpenOptions
Indicates that opening the file creates the file if it doesn’t exist.
static var directory: OpenOptions
Indicates that opening the file only succeeds if the file is a directory.
static var exclusiveCreate: OpenOptions
Indicates that opening the file creates the file, expecting that it doesn’t exist.
static var noFollow: OpenOptions
Indicates that opening the file doesn’t follow symlinks.
static var nonBlocking: OpenOptions
Indicates that opening the file doesn’t wait for the file or device to become available.
static var truncate: OpenOptions
Indicates that opening the file truncates the file if it exists.
Instance members
var debugDescription: String
A textual representation of the open options, suitable for debugging.
var description: String
A textual representation of the open options.
var rawValue: CInt
The raw C options.
Type features
init(
) Creates an empty option set.
init<S>(S
) Creates a new set from a finite sequence of items.
init(arrayLiteral: Self.Element...
) Creates a set containing the elements of the given array literal.
init(from: any Decoder
) throws Creates a new instance by decoding from the given decoder, when the type’s
RawValue
isInt32
.static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.
Instance features
var hashValue: Int
var isEmpty: Bool
A Boolean value that indicates whether the set has no elements.
func contains(Self
) -> Bool Returns a Boolean value that indicates whether a given element is a member of the option set.
func encode(to: any Encoder
) throws Encodes this value into the given encoder, when the type’s
RawValue
isInt32
.func formIntersection(Self
) Removes all elements of this option set that are not also present in the given set.
func formSymmetricDifference(Self
) Replaces this set with a new set containing all elements contained in either this set or the given set, but not in both.
func formUnion(Self
) Inserts the elements of another set into this option set.
func hash(into: inout Hasher
) func insert(Self.Element
) -> (inserted: Bool, memberAfterInsert: Self.Element) Adds the given element to the option set if it is not already a member.
func intersection(Self
) -> Self Returns a new option set with only the elements contained in both this set and the given set.
func isDisjoint(with: Self
) -> Bool Returns a Boolean value that indicates whether the set has no members in common with the given set.
func isStrictSubset(of: Self
) -> Bool Returns a Boolean value that indicates whether this set is a strict subset of the given set.
func isStrictSuperset(of: Self
) -> Bool Returns a Boolean value that indicates whether this set is a strict superset of the given set.
func isSubset(of: Self
) -> Bool Returns a Boolean value that indicates whether the set is a subset of another set.
func isSuperset(of: Self
) -> Bool Returns a Boolean value that indicates whether the set is a superset of the given set.
func remove(Self.Element
) -> Self.Element? Removes the given element and all elements subsumed by it.
func subtract(Self
) Removes the elements of the given set from this set.
func subtracting(Self
) -> Self Returns a new set containing the elements of this set that do not occur in the given set.
func symmetricDifference(Self
) -> Self Returns a new option set with the elements contained in this set or in the given set, but not in both.
func union(Self
) -> Self Returns a new option set of the elements contained in this set, in the given set, or in both.
func update(with: Self.Element
) -> Self.Element? Inserts the given element into the set.