write(_:)
Writes the contents of a string at the current file offset.
@discardableResult func write(_ string: String) throws(Errno) -> Int
Parameters
- string
REQUIRED The string being written.
Returns
The number of bytes that were written.
Writes the contents of a string at the current file offset.
@discardableResult func write(_ string: String) throws(Errno) -> Int
REQUIRED The string being written.
The number of bytes that were written.
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.
@frozen struct String
A Unicode string value that is a collection of characters.
struct Errno
The Errno struct lists all the possible errors.
@frozen struct Int
A signed integer value type.
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.
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(_ 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 AccessMode
The desired read and write access for a newly opened file.
struct OpenOptions
Options that specify behavior for a newly-opened file.
struct SeekOrigin
Options for specifying what a file descriptor’s offset is relative to.