AccessMode
The desired read and write access for a newly opened file.
struct AccessMode
The desired read and write access for a newly opened file.
struct AccessMode
import SwiftIO
The SwiftIO library allows you to access and control the hardware in an easy way.
struct FileDescriptor
The FileDescriptor struct is used to perform low-level file operations.
static func open(_ path: String, _ mode: FileDescriptor.AccessMode = .readWrite, options: FileDescriptor.OpenOptions = FileDescriptor.OpenOptions()) throws(Errno) -> FileDescriptor
Open or creates, if does not exist, file.
struct OpenOptions
Options that specify behavior for a newly-opened file.
var size: Int { get }
Size of the file.
func close() throws(Errno)
Flushes the associated stream and closes the file.
@discardableResult func read(fromAbsoluteOffest offset: Int, into buffer: inout [UInt8], count: Int? = nil) throws(Errno) -> Int
Reads bytes at the specified offset into a buffer.
@discardableResult func read(fromAbsoluteOffest offset: Int, into buffer: UnsafeMutableRawBufferPointer, count: Int? = nil) throws(Errno) -> Int
Reads bytes at the specified offset into a buffer.
@discardableResult func read(into buffer: inout [UInt8], count: Int? = nil) throws(Errno) -> Int
Reads bytes at the current file offset into a buffer.
@discardableResult func read(into buffer: UnsafeMutableRawBufferPointer, count: Int? = nil) throws(Errno) -> Int
Reads bytes at the current file offset into a buffer.
@discardableResult func seek(offset: Int, from whence: SeekOrigin = .start) throws(Errno) -> Int
Repositions the offset for the given file descriptor.
func sync() throws(Errno)
Flushes any cached write of an open file.
func tell() throws(Errno) -> Int
Get current file position.
@discardableResult func write(_ string: String) throws(Errno) -> Int
Writes the contents of a string at the current file offset.
@discardableResult func write(_ buffer: UnsafeRawBufferPointer, count: Int? = nil) throws(Errno) -> Int
Writes the contents of a buffer at the current file offset.
@discardableResult func write(_ buffer: [UInt8], count: Int? = nil) throws(Errno) -> Int
Writes the contents of a buffer at the current file offset.
@discardableResult func write(toAbsoluteOffset offset: Int, _ buffer: UnsafeRawBufferPointer, count: Int? = nil) throws(Errno) -> Int
Writes the contents of a buffer at the specified offset.
@discardableResult func write(toAbsoluteOffset offset: Int, _ buffer: [UInt8], count: Int? = nil) throws(Errno) -> Int
Writes the contents of a buffer at the specified offset.
struct SeekOrigin
Options for specifying what a file descriptor’s offset is relative to.
protocol RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
init(rawValue: UInt8)
static var readOnly: AccessMode { get }
Opens the file for reading only.
static var readWrite: AccessMode { get }
Opens the file for reading and writing.
static var writeOnly: AccessMode { get }
Opens the file for writing only.
var rawValue: UInt8