Flags
Flags
allows to specify additional flags to Mode
, such as permission for file creation.
struct Flags
Flags
allows to specify additional flags to Mode
, such as permission for file creation.
struct Flags
import NIOCore
The core abstractions that make up SwiftNIO.
final class NIOFileHandle
Deprecated. NIOFileHandle
is a handle to an open file descriptor.
convenience init(_deprecatedPath path: String) throws
Open a new NIOFileHandle
. This operation is blocking.
convenience init(_deprecatedPath path: String, mode: Mode = .read, flags: Flags = .default) throws
Open a new NIOFileHandle
. This operation is blocking.
init(_deprecatedTakingOwnershipOfDescriptor descriptor: CInt)
Create a NIOFileHandle
taking ownership of descriptor
. You must call NIOFileHandle.close
or NIOFileHandle.takeDescriptorOwnership
before this object can be safely released.
var description: String { get }
var isOpen: Bool { get }
func close() throws
func duplicate() throws -> NIOFileHandle
Duplicates this NIOFileHandle
. This means that a new NIOFileHandle
object with a new underlying file descriptor is returned. The caller takes ownership of the returned NIOFileHandle
and is responsible for closing it.
func takeDescriptorOwnership() throws -> CInt
Take the ownership of the underlying file descriptor. This is similar to close()
but the underlying file descriptor remains open. The caller is responsible for closing the file descriptor by some other means.
func withUnsafeFileDescriptor<T>(_ body: (CInt) throws -> T) throws -> T
struct Mode
Mode
represents file access modes.
convenience init(descriptor: CInt)
Create a NIOFileHandle
taking ownership of descriptor
. You must call NIOFileHandle.close
or NIOFileHandle.takeDescriptorOwnership
before this object can be safely released.
convenience init(path: String) throws
Open a new NIOFileHandle
. This operation is blocking.
convenience init(path: String, mode: Mode = .read, flags: Flags = .default) throws
Open a new NIOFileHandle
. This operation is blocking.
protocol Sendable
static let `default`: NIOFileHandle.Flags
static let defaultPermissions: mode_t
static func allowFileCreation(posixMode: NIOPOSIXFileMode = defaultPermissions) -> Flags
Allows file creation when opening file for writing. File owner is set to the effective user ID of the process.
static func posix(flags: CInt, mode: NIOPOSIXFileMode) -> Flags
Allows the specification of POSIX flags (e.g. O_TRUNC
) and mode (e.g. S_IWUSR
)