Sample code for 30+ languages & platforms
C

Transition from SFtp.ReadDir to SFtp.ReadDirListing

Provides instructions for replacing deprecated ReadDir method calls with ReadDirListing.

Chilkat C Downloads

C
#include <C_CkSFtp.h>
#include <C_CkSFtpDir.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkSFtp sftp;
    const char *handle;
    HCkSFtpDir dirObj;
    HCkSFtpDir dirOut;

    success = FALSE;

    sftp = CkSFtp_Create();

    //  ...
    //  ...

    handle = CkSFtp_openDir(sftp,".");
    //  ...
    //  ...

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

    dirObj = CkSFtp_ReadDir(sftp,handle);
    if (CkSFtp_getLastMethodSuccess(sftp) == FALSE) {
        printf("%s\n",CkSFtp_lastErrorText(sftp));
        CkSFtp_Dispose(sftp);
        return;
    }

    //  ...
    //  ...

    CkSFtpDir_Dispose(dirObj);

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

    dirOut = CkSFtpDir_Create();
    success = CkSFtp_ReadDirListing(sftp,handle,dirOut);
    if (success == FALSE) {
        printf("%s\n",CkSFtp_lastErrorText(sftp));
        CkSFtp_Dispose(sftp);
        CkSFtpDir_Dispose(dirOut);
        return;
    }

    //  ...
    //  ...

    CkSFtp_CloseHandle(sftp,handle);


    CkSFtp_Dispose(sftp);
    CkSFtpDir_Dispose(dirOut);

    }