Sample code for 30+ languages & platforms
Swift Requires Chilkat v11.0.0+

Transition from SFtp.ReadDir to SFtp.ReadDirListing

Provides instructions for replacing deprecated ReadDir method calls with ReadDirListing.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let sftp = CkoSFtp()!

    //  ...
    //  ...

    var handle: String? = sftp.openDir(path: ".")
    //  ...
    //  ...

    //  ------------------------------------------------------------------------
    //  The ReadDir method is deprecated:

    var dirObj: CkoSFtpDir? = sftp.readDir(sftpHandle: handle)
    if sftp.lastMethodSuccess == false {
        print("\(sftp.lastErrorText!)")
        return
    }

    //  ...
    //  ...

    dirObj = nil

    //  ------------------------------------------------------------------------
    //  Do the equivalent using ReadDirListing.
    //  Your application creates a new, empty SFtpDir object which is passed 
    //  in the last argument and filled upon success.

    let dirOut = CkoSFtpDir()!
    success = sftp.readDirListing(handle: handle, dirObj: dirOut)
    if success == false {
        print("\(sftp.lastErrorText!)")
        return
    }

    //  ...
    //  ...

    sftp.closeHandle(sftpHandle: handle)

}