FileDescriptor
public typealias FileDescriptor = CInt
POSIX File Descriptor
-
Returns the file handle associated with the standard input file. Conventionally this is a terminal device on which the user enters a stream of data. There is one standard input file handle per process; it is a shared instance. When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.
Declaration
Swift
public static let standardInput: FileDescriptor = 0
Return Value
The shared file handle associated with the standard input file.
-
Returns the file handle associated with the standard output file. Conventionally this is a terminal device that receives a stream of data from a program. There is one standard output file handle per process; it is a shared instance. When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.
Declaration
Swift
public static let standardOutput: FileDescriptor = 1
Return Value
The shared file handle associated with the standard output file.
-
Returns the file handle associated with the standard error file. Conventionally this is a terminal device to which error messages are sent. There is one standard error file handle per process; it is a shared instance. When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.
Declaration
Swift
public static let standardError: FileDescriptor = 2
Return Value
The shared file handle associated with the standard error file.
-
Returns a file handle associated with a null device. You can use null-device file handles as “placeholders” for standard-device file handles or in collection objects to avoid exceptions and other errors resulting from messages being sent to invalid file handles. Read messages sent to a null-device file handle return an end-of-file indicator (empty Data) rather than raise an exception. Write messages are no-ops, whereas fileDescriptor returns an illegal value. Other methods are no-ops or return “sensible” values. When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.
Declaration
Swift
public static let nullDevice: FileDescriptor = open("/dev/null", O_RDWR | O_BINARY)
Return Value
A file handle associated with a null device.