Structures

The following structures are available globally.

  • The FileDescriptor struct is used to perform low-level file operations.

    Example: Open and read a ASCII file

    import SwiftIO
    
    // Open the file located in "/subDir/hello.txt"
    let file = FileDescriptor.open("/SD:/subDir/hello.txt")
    
    //Initialize a buffer to store the reading bytes.
    var buffer = UnsafeMutableRawBufferPointer.allocate(byteCount: 10, alignment: 4)
    
    // Read bytes into the buffer
    file.read(into: buffer)
    
    // Print the reding bytes.
    for i in 0..<buffer.count {
        print(buffer[i])
    }
    
    while true {
        sleep(ms: 1000)
    }
    
    See more

    Declaration

    Swift

    public struct FileDescriptor