SFtp C Library Reference

SFtp

SFTP implementation for file transfer and remote file management over SSH.

Create/Dispose

HCkSFtp CkSFtp_Create(void);

Creates an instance of the CkSFtp object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.

void CkSFtp_Dispose(HCkSFtp handle);

Objects created by calling CkSFtp_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

C "Properties"

void CkSFtp_getAccumulateBuffer(HCkSFtp cHandle, HCkByteData retval);

Contains the bytes downloaded from a remote file via the AccumulateBytes method call. Each call to AccumulateBytes appends to this buffer. To clear this buffer, call the ClearAccumulateBuffer method.

void CkSFtp_getClientIdentifier(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putClientIdentifier(HCkSFtp cHandle, const char *newVal);

The client-identifier string to be used when connecting to an SSH/SFTP server. Defaults to "SSH-2.0-PuTTY_Local:_Jun_27_2008_16:28:58". (This string is used to mimic PuTTY because some servers are known to disconnect from clients with unknown client identifiers.)

int CkSFtp_getConnectTimeoutMs(HCkSFtp cHandle);
void CkSFtp_putConnectTimeoutMs(HCkSFtp cHandle, int newVal);

Maximum number of milliseconds to wait when connecting to an SSH server.

int CkSFtp_getDisconnectCode(HCkSFtp cHandle);

If the SSH/SFTP server sent a DISCONNECT message when closing the connection, this property contains the "reason code" as specified in RFC 4253:

           Symbolic name                                reason code
           -------------                                -----------
      SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT             1
      SSH_DISCONNECT_PROTOCOL_ERROR                          2
      SSH_DISCONNECT_KEY_EXCHANGE_FAILED                     3
      SSH_DISCONNECT_RESERVED                                4
      SSH_DISCONNECT_MAC_ERROR                               5
      SSH_DISCONNECT_COMPRESSION_ERROR                       6
      SSH_DISCONNECT_SERVICE_NOT_AVAILABLE                   7
      SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED          8
      SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE                 9
      SSH_DISCONNECT_CONNECTION_LOST                        10
      SSH_DISCONNECT_BY_APPLICATION                         11
      SSH_DISCONNECT_TOO_MANY_CONNECTIONS                   12
      SSH_DISCONNECT_AUTH_CANCELLED_BY_USER                 13
      SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE         14
      SSH_DISCONNECT_ILLEGAL_USER_NAME                      15

void CkSFtp_getDisconnectReason(HCkSFtp cHandle, HCkString retval);

If the SSH/SFTP server sent a DISCONNECT message when closing the connection, this property contains a descriptive string for the "reason code" as specified in RFC 4253.

BOOL CkSFtp_getEnableCache(HCkSFtp cHandle);
void CkSFtp_putEnableCache(HCkSFtp cHandle, BOOL newVal);

Controls whether the component keeps an internal file size & attribute cache. The cache affects the following methods: GetFileSize32, GetFileSize64, GetFileSizeStr, GetFileCreateTime, GetFileLastAccess, GetFileLastModified, GetFileOwner, GetFileGroup, and GetFilePermissions.

The file attribute cache exists to minimize communications with the SFTP server. If the cache is enabled, then a request for any single attribute will cause all of the attributes to be cached. A subsequent request for a different attribute of the same file will be fulfilled from cache, eliminating the need for a message to be sent to the SFTP server.

Note: Caching only occurs when filenames are used, not handles.

void CkSFtp_getFilenameCharset(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putFilenameCharset(HCkSFtp cHandle, const char *newVal);

Automatically set during the InitializeSftp method if the server sends a filename-charset name-value extension. Otherwise, may be set directly to the name of a charset, such as "utf-8", "iso-8859-1", "windows-1252", etc. ("ansi" is also a valid choice.) Incoming filenames are interpreted as utf-8 if no FilenameCharset is set. Outgoing filenames are sent using utf-8 by default. Otherwise, incoming and outgoing filenames use the charset specified by this property.

BOOL CkSFtp_getForceV3(HCkSFtp cHandle);
void CkSFtp_putForceV3(HCkSFtp cHandle, BOOL newVal);

If set to true, forces the client to choose version 3 of the SFTP protocol, even if the server supports a higher version. The default value of this property is false.

int CkSFtp_getHeartbeatMs(HCkSFtp cHandle);
void CkSFtp_putHeartbeatMs(HCkSFtp cHandle, int newVal);

This is the number of milliseconds between each AbortCheck event callback. The AbortCheck callback allows an application to abort any SFTP operation prior to completion. If HeartbeatMs is 0 (the default), no AbortCheck event callbacks will fire.

void CkSFtp_getHostKeyFingerprint(HCkSFtp cHandle, HCkString retval);

Set after connecting to an SSH/SFTP server. The format of the fingerprint looks like this: "ssh-rsa 1024 68:ff:d1:4e:6c:ff:d7:b0:d6:58:73:85:07:bc:2e:d5"

void CkSFtp_getHttpProxyAuthMethod(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putHttpProxyAuthMethod(HCkSFtp cHandle, const char *newVal);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "LOGIN" or "NTLM".

void CkSFtp_getHttpProxyHostname(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putHttpProxyHostname(HCkSFtp cHandle, const char *newVal);

If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).

void CkSFtp_getHttpProxyPassword(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putHttpProxyPassword(HCkSFtp cHandle, const char *newVal);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.

int CkSFtp_getHttpProxyPort(HCkSFtp cHandle);
void CkSFtp_putHttpProxyPort(HCkSFtp cHandle, int newVal);

If an HTTP proxy is to be used, set this property to the HTTP proxy port number. (Two commonly used HTTP proxy ports are 8080 and 3128.)

void CkSFtp_getHttpProxyUsername(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putHttpProxyUsername(HCkSFtp cHandle, const char *newVal);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.

int CkSFtp_getIdleTimeoutMs(HCkSFtp cHandle);
void CkSFtp_putIdleTimeoutMs(HCkSFtp cHandle, int newVal);

Causes SFTP operations to fail when progress for sending or receiving data halts for more than this number of milliseconds. Setting IdleTimeoutMs = 0 (the default) allows the application to wait indefinitely.

int CkSFtp_getInitializeFailCode(HCkSFtp cHandle);

The InitializeSftp method call opens a channel for the SFTP session. If the request to open a channel fails, this property contains a code that identifies the reason for failure. The reason codes are defined in RFC 4254 and are reproduced here:

             Symbolic name                           reason code
             -------------                           -----------
            SSH_OPEN_ADMINISTRATIVELY_PROHIBITED          1
            SSH_OPEN_CONNECT_FAILED                       2
            SSH_OPEN_UNKNOWN_CHANNEL_TYPE                 3
            SSH_OPEN_RESOURCE_SHORTAGE                    4

void CkSFtp_getInitializeFailReason(HCkSFtp cHandle, HCkString retval);

The InitializeSftp method call opens a channel for the SFTP session. If the request to open a channel fails, this property contains a description of the reason for failure. (It contains descriptive text matching the InitializeFailCode property.)

BOOL CkSFtp_getIsConnected(HCkSFtp cHandle);

Returns true if connected to the SSH server. Note: This does not mean authentication has happened or InitializeSftp has already succeeded. It only means that the connection has been established by calling Connect.

BOOL CkSFtp_getKeepSessionLog(HCkSFtp cHandle);
void CkSFtp_putKeepSessionLog(HCkSFtp cHandle, BOOL newVal);

Controls whether communications to/from the SFTP server are saved to the SessionLog property. The default value is false. If this property is set to true, the contents of the SessionLog property will continuously grow as SFTP activity transpires. The purpose of the KeepSessionLog / SessionLog properties is to help in debugging any future problems that may arise.

void CkSFtp_getLastErrorHtml(HCkSFtp cHandle, HCkString retval);

Error information in HTML format for the last method called.

void CkSFtp_getLastErrorText(HCkSFtp cHandle, HCkString retval);

Error information in plain-text format for the last method called.

void CkSFtp_getLastErrorXml(HCkSFtp cHandle, HCkString retval);

Error information in XML format for the last method called.

int CkSFtp_getMaxPacketSize(HCkSFtp cHandle);
void CkSFtp_putMaxPacketSize(HCkSFtp cHandle, int newVal);

The maximum packet length to be used in the underlying SSH transport protocol. The default value is 32768. (This should generally be left unchanged.)

BOOL CkSFtp_getPreserveDate(HCkSFtp cHandle);
void CkSFtp_putPreserveDate(HCkSFtp cHandle, BOOL newVal);

If true, then the file last-modified and create date/time will be preserved for downloaded files. The default value is false.

int CkSFtp_getProtocolVersion(HCkSFtp cHandle);

The negotiated SFTP protocol version, which should be a value between 3 and 6 inclusive. When the InitializeSftp method is called, the Chilkat SFTP client sends it's highest supported protocol version to the server, and the server sends it's SFTP protocol version in response. The negotiated protocol (i.e. the protocol version used for the session) is the lower of the two numbers. If the SFTP server's protocol version is lower than 6, some file date/attributes are not supported because they are not supported by the earlier protocol version. These exceptions are noted throughout the reference documentation.

void CkSFtp_getSessionLog(HCkSFtp cHandle, HCkString retval);

Contains a log of the messages sent to/from the SFTP server. To enable session logging, set the KeepSessionLog property = true. Note: This property is not a filename -- it is a string property that contains the session log data.

void CkSFtp_getSocksHostname(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSocksHostname(HCkSFtp cHandle, const char *newVal);

The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).

void CkSFtp_getSocksPassword(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSocksPassword(HCkSFtp cHandle, const char *newVal);

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

int CkSFtp_getSocksPort(HCkSFtp cHandle);
void CkSFtp_putSocksPort(HCkSFtp cHandle, int newVal);

The SOCKS4/SOCKS5 proxy port. The default value is 1080. This property only applies if a SOCKS proxy is used (if the SocksVersion property is set to 4 or 5).

void CkSFtp_getSocksUsername(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSocksUsername(HCkSFtp cHandle, const char *newVal);

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

int CkSFtp_getSocksVersion(HCkSFtp cHandle);
void CkSFtp_putSocksVersion(HCkSFtp cHandle, int newVal);

SocksVersion May be set to one of the following integer values:

0 - No SOCKS proxy is used. This is the default.
4 - Connect via a SOCKS4 proxy.
5 - Connect via a SOCKS5 proxy.

BOOL CkSFtp_getTcpNoDelay(HCkSFtp cHandle);
void CkSFtp_putTcpNoDelay(HCkSFtp cHandle, BOOL newVal);

To be documented soon...

BOOL CkSFtp_getUtcMode(HCkSFtp cHandle);
void CkSFtp_putUtcMode(HCkSFtp cHandle, BOOL newVal);

If true, then date/times are returned as UTC times. If false (the default) then date/times are returned as local times.

BOOL CkSFtp_getUtf8(HCkSFtp cHandle);
void CkSFtp_putUtf8(HCkSFtp cHandle, BOOL newVal);

To be documented soon...

BOOL CkSFtp_getVerboseLogging(HCkSFtp cHandle);
void CkSFtp_putVerboseLogging(HCkSFtp cHandle, BOOL newVal);

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false.

void CkSFtp_getVersion(HCkSFtp cHandle, HCkString retval);

The version of the SFTP component, such as "2.3.0".

C "Methods"

int CkSFtp_AccumulateBytes(HCkSFtp cHandle, const char *handle, int maxBytes);

Downloads bytes from an open file and appends them to the AccumulateBuffer. The handle is a file handle returned by the OpenFile method. The maxBytes is the maximum number of bytes to read. If the end-of-file is reached prior to reading the number of requested bytes, then fewer bytes may be returned.

Returns the number of bytes downloaded and appended to AccumulateBuffer. Returns -1 on error.

void CkSFtp_Add64(HCkSFtp cHandle, const char *n1, const char *n2, HCkString outStr);

Convenience method for 64-bit addition. Allows for two 64-bit integers to be passed as decimal strings and returns the sum in a decimal sting.

BOOL CkSFtp_AuthenticatePk(HCkSFtp cHandle, const char *username, HCkSshKey privateKey);

Authenticates with the SSH server using public-key authentication. The corresponding public key must have been installed on the SSH server for the username. Authentication will succeed if the matching privateKey is provided.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_AuthenticatePw(HCkSFtp cHandle, const char *login, const char *password);

Authenticates with the SSH server using a login and password.

An SFTP session always begins by first calling Connect to connect to the SSH server, then calling either AuthenticatePw or AuthenticatePk to login, and finally calling InitializeSftp.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns TRUE for success, FALSE for failure.

void CkSFtp_ClearAccumulateBuffer(HCkSFtp cHandle);

Clears the contents of the AccumulateBuffer property.

void CkSFtp_ClearCache(HCkSFtp cHandle);

Clears the internal file attribute cache. (Please refer to the EnableCache property for more information about the file attribute cache.)

void CkSFtp_ClearSessionLog(HCkSFtp cHandle);

Clears the contents of the SessionLog property.

BOOL CkSFtp_CloseHandle(HCkSFtp cHandle, const char *handle);

Closes a file on the SSH/SFTP server. handle is a file handle returned from a previous call to OpenFile.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_Connect(HCkSFtp cHandle, const char *hostname, int port);

Connects to an SSH/SFTP server. The hostname may be a hostname or an IP address (example: 192.168.1.10). The port is typically 22, which is the standard port for SSH servers.

An SFTP session always begins by first calling Connect to connect to the SSH server, then calling either AuthenticatePw or AuthenticatePk to login, and finally calling InitializeSftp.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_CopyFileAttr(HCkSFtp cHandle, const char *localFilename, const char *remoteFilenameOrHandle, BOOL bIsHandle);

Sets the date/time and other attributes of a remote file to be equal to that of a local file.

The attributes copied depend on the SFTP version of the server:

SFTP v3 (and below)
    Last-Modified Date/Time
    Last-Access Date/Time

SFTP v4, v5
    Last-Modified Date/Time
    Last-Access Date/Time
    Create Date/Time

SFTP v6 (and above)
    Last-Modified Date/Time
    Last-Access Date/Time
    Create Date/Time
    Read-Only Flag
    Hidden Flag
    Archive Flag
    Compressed Flag
    Encrypted Flag

Notes:
(1) The Last-Access date/time may or may not be set. Chilkat has found that the Last-Access time is set to the current date/time, which is probably a result of the operating system setting it based on when the SFTP server is touching the file.
(2) At the time of this writing, it is unknown whether the compressed/encryption settings for a local file are transferred to the remote file. For example, does the remote file become compressed and/or encrypted just by setting the flags? It may depend on the SFTP server and/or the remote filesystem.
(3) Dates/times are sent in GMT. SFTP servers should convert GMT times to local time zones.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_CreateDir(HCkSFtp cHandle, const char *path);

Creates a directory on the SFTP server.

Returns TRUE for success, FALSE for failure.

void CkSFtp_Disconnect(HCkSFtp cHandle);

Disconnects from the SSH server.

BOOL CkSFtp_DownloadFile(HCkSFtp cHandle, const char *handle, const char *toFilename);

Downloads a file from the SSH server to the local filesystem. There are no limitations on file size and the data is streamed from SSH server to the local file. handle is a file handle returned by a previous call to OpenFile.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_DownloadFileByName(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Simplified method for downloading files.

Returns TRUE for success, FALSE for failure.

Understanding SFTP Absolute FilePaths

BOOL CkSFtp_Eof(HCkSFtp cHandle, const char *handle);

Returns true if the last read operation for a handle reached the end of file. Otherwise returns false. If an invalid handle is passed, a value of true is returned.

BOOL CkSFtp_GetFileCreateTime(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle, SYSTEMTIME *sysTime);

Returns the create date/time for a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

Note: Servers running the SFTP v3 protocol or lower do not have the ability to return a file's creation date/time.

BOOL CkSFtp_GetFileGroup(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);

Returns the group of a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

Note: Servers running the SFTP v3 protocol or lower do not have the ability to return a file's group name. Instead, the decimal GID of the file is returned.

BOOL CkSFtp_GetFileLastAccess(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle, SYSTEMTIME *sysTime);

Returns the last-access date/time for a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

BOOL CkSFtp_GetFileLastModified(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle, SYSTEMTIME *sysTime);

Returns the last-modified date/time for a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

BOOL CkSFtp_GetFileOwner(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);

Returns the owner of a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

Note: Servers running the SFTP v3 protocol or lower do not have the ability to return a file's owner name. Instead, the decimal UID of the file is returned.

int CkSFtp_GetFilePermissions(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the access permisssions flags of a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

unsigned long CkSFtp_GetFileSize32(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the size in bytes of a file on the SSH server. If the file size exceeds what can be represented in 32-bits, a value of -1 is returned. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

BOOL CkSFtp_GetFileSizeStr(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);

Returns the size in bytes (in decimal string form) of a file on the SSH server. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

Note: This method exists for environments that do not have 64-bit integer support. The Add64 method is provided for 64-bit addition, and other methods such as ReadFileBytes64s allow for 64-bit values to be passed as strings.

BOOL CkSFtp_InitializeSftp(HCkSFtp cHandle);

Intializes the SFTP subsystem. This should be called after connecting and authenticating. An SFTP session always begins by first calling Connect to connect to the SSH server, then calling either AuthenticatePw or AuthenticatePk to login, and finally calling InitializeSftp.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

If this method fails, the reason may be present in the InitializeFailCode and InitializeFailReason properties (assuming the failure occurred when trying to open the SFTP session channel).

Returns TRUE for success, FALSE for failure.

Error Explained: Received FAILURE response to subsystem request.

BOOL CkSFtp_LastReadFailed(HCkSFtp cHandle, const char *handle);

Returns true if the last read on the specified handle failed. Otherwise returns false.

int CkSFtp_LastReadNumBytes(HCkSFtp cHandle, const char *handle);

Returns the number of bytes received by the last read on a specified channel.

BOOL CkSFtp_OpenDir(HCkSFtp cHandle, const char *path, HCkString outStr);

Opens a directory for reading. To get a directory listing, first open the directory by calling this method, then call ReadDir to read the directory, and finally call CloseHandle to close the directory.

The SFTP protocol represents file names as strings. File names are assumed to use the slash ('/') character as a directory separator.

File names starting with a slash are "absolute", and are relative to the root of the file system. Names starting with any other character are relative to the user's default directory (home directory). Note that identifying the user is assumed to take place outside of this protocol.

Servers SHOULD interpret a path name component ".." as referring to the parent directory, and "." as referring to the current directory.

An empty path name is valid, and it refers to the user's default directory (usually the user's home directory).

Understanding SFTP Absolute FilePaths

BOOL CkSFtp_OpenFile(HCkSFtp cHandle, const char *filename, const char *access, const char *createDisp, HCkString outStr);

Opens or creates a file on the remote system. Returns a handle which may be passed to methods for reading and/or writing the file. access should be one of the following strings: "readOnly", "writeOnly", or "readWrite". createDisposition is a comma-separated list of keywords to provide more control over how the file is opened or created. One of the following keywords must be present: "createNew", "createTruncate", "openExisting", "openOrCreate", or "truncateExisting". All other keywords are optional. The list of keywords and their meanings are shown here:

createNew
A new file is created; if the file already exists the method fails.

createTruncate
A new file is created; if the file already exists, it is opened and truncated.

openExisting
An existing file is opened. If the file does not exist the method fails.

openOrCreate
If the file exists, it is opened. If the file does not exist, it is created.

truncateExisting
An existing file is opened and truncated. If the file does not exist the method fails.

appendData
Data is always written at the end of the file. Data is not required to be appended atomically. This means that if multiple writers attempt to append data simultaneously, data from the first may be lost.

appendDataAtomic
Data is always written at the end of the file. Data MUST be written atomically so that there is no chance that multiple appenders can collide and result in data being lost.

textMode
Indicates that the server should treat the file as text and convert it to the canonical newline convention in use. When a file is opened with this flag, data is always appended to the end of the file. Servers MUST process multiple, parallel reads and writes correctly in this mode.

blockRead
The server MUST guarantee that no other handle has been opened with read access, and that no other handle will be opened with read access until the client closes the handle. (This MUST apply both to other clients and to other processes on the server.) In a nutshell, this opens the file in non-sharing mode.

blockWrite
The server MUST guarantee that no other handle has been opened with write access, and that no other handle will be opened with write access until the client closes the handle. (This MUST apply both to other clients and to other processes on the server.) In a nutshell, this opens the file in non-sharing mode.

blockDelete
The server MUST guarantee that the file itself is not deleted in any other way until the client closes the handle. No other client or process is allowed to open the file with delete access.

blockAdvisory
If set, the above "block" modes are advisory. In advisory mode, only other accesses that specify a "block" mode need be considered when determining whether the "block" can be granted, and the server need not prevent I/O operations that violate the block mode. The server MAY perform mandatory locking even if the blockAdvisory flag is set.

noFollow
If the final component of the path is a symlink, then the open MUST fail.

deleteOnClose
The file should be deleted when the last handle to it is closed. (The last handle may not be an sftp-handle.) This MAY be emulated by a server if the OS doesn't support it by deleting the file when this handle is closed.

accessAuditAlarmInfo
The client wishes the server to enable any privileges or extra capabilities that the user may have in to allow the reading and writing of AUDIT or ALARM access control entries.

accessBackup
The client wishes the server to enable any privileges or extra capabilities that the user may have in order to bypass normal access checks for the purpose of backing up or restoring files.

backupStream
This flag indicates that the client wishes to read or write a backup stream. A backup stream is a system dependent structured data stream that encodes all the information that must be preserved in order to restore the file from backup medium. The only well defined use for backup stream data read in this fashion is to write it to the same server to a file also opened using the backupStream flag. However, if the server has a well defined backup stream format, there may be other uses for this data outside the scope of this protocol.

Understanding SFTP Absolute FilePaths

HCkSFtpDir CkSFtp_ReadDir(HCkSFtp cHandle, const char *handle);

Reads the contents of a directory and returns the directory listing (as an object). The handle returned by OpenDir should be passed to this method.

BOOL CkSFtp_ReadFileBytes(HCkSFtp cHandle, const char *handle, int numBytes, HCkByteData outBytes);

Reads file data from a remote file on the SSH server. The handle is a file handle returned by the OpenFile method. The numBytes is the maximum number of bytes to read. If the end-of-file is reached prior to reading the number of requested bytes, then fewer bytes may be returned.

To read an entire file, one may call ReadFileBytes repeatedly until Eof(handle) returns true.

BOOL CkSFtp_ReadFileBytes32(HCkSFtp cHandle, const char *handle, int offset, int numBytes, HCkByteData outBytes);

Reads file data from a remote file on the SSH server. The handle is a file handle returned by the OpenFile method. The offset is measured in bytes relative to the beginning of the file. (64-bit offsets are supported via the ReadFileBytes64 and ReadFileBytes64s methods.) The offset is ignored if the "textMode" flag was specified during the OpenFile. The numBytes is the maximum number of bytes to read. If the end-of-file is reached prior to reading the number of requested bytes, then fewer bytes may be returned.

BOOL CkSFtp_ReadFileBytes64(HCkSFtp cHandle, const char *handle, __int64 offset64, int numBytes, HCkByteData outBytes);

Reads file data from a remote file on the SSH server. The handle is a file handle returned by the OpenFile method. The offset is a 64-bit integer measured in bytes relative to the beginning of the file. The offset is ignored if the "textMode" flag was specified during the OpenFile. The numBytes is the maximum number of bytes to read. If the end-of-file is reached prior to reading the number of requested bytes, then fewer bytes may be returned.

BOOL CkSFtp_ReadFileBytes64s(HCkSFtp cHandle, const char *handle, const char *offset64, int numBytes, HCkByteData outBytes);

(This method exists for systems that do not support 64-bit integers. The 64-bit integer offset is passed as a decimal string instead.)

Reads file data from a remote file on the SSH server. The handle is a file handle returned by the OpenFile method. The offset is a 64-bit integer represented as a decimal string. It represents an offset in bytes from the beginning of the file. The offset is ignored if the "textMode" flag was specified during the OpenFile. The numBytes is the maximum number of bytes to read. If the end-of-file is reached prior to reading the number of requested bytes, then fewer bytes may be returned.

BOOL CkSFtp_ReadFileText(HCkSFtp cHandle, const char *handle, int numBytes, const char *charset, HCkString outStr);

This method is identical to ReadFileBytes except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

To read an entire file, one may call ReadFileText repeatedly until Eof(handle) returns true.

BOOL CkSFtp_ReadFileText32(HCkSFtp cHandle, const char *handle, int offset32, int numBytes, const char *charset, HCkString outStr);

This method is identical to ReadFileBytes32 except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

BOOL CkSFtp_ReadFileText64(HCkSFtp cHandle, const char *handle, __int64 offset64, int numBytes, const char *charset, HCkString outStr);

This method is identical to ReadFileBytes64 except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

BOOL CkSFtp_ReadFileText64s(HCkSFtp cHandle, const char *handle, const char *offset64, int numBytes, const char *charset, HCkString outStr);

This method is identical to ReadFileBytes64s except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

BOOL CkSFtp_RealPath(HCkSFtp cHandle, const char *originalPath, const char *composePath, HCkString outStr);

This method can be used to have the server canonicalize any given path name to an absolute path. This is useful for converting path names containing ".." components or relative pathnames without a leading slash into absolute paths. The absolute path is returned by this method.

originalPath is the first component of the path which the client wishes resolved into a absolute canonical path. This may be the entire path.

The composePath is a path which the client wishes the server to compose with the original path to form the new path. This field is optional and may be set to a zero-length string.

The server will take the originalPath and apply the composePath as a modification to it. composePath may be relative to originalPath or may be an absolute path, in which case originalPath will be discarded. The composePath may be zero length.

Note: Servers running SFTP v4 and below do not support composePath.

BOOL CkSFtp_RemoveDir(HCkSFtp cHandle, const char *path);

Deletes a directory on the remote server. Most (if not all) SFTP servers require that the directorybe empty of files before it may be deleted.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_RemoveFile(HCkSFtp cHandle, const char *filename);

Deletes a file on the SFTP server.

Returns TRUE for success, FALSE for failure.

Understanding SFTP Absolute FilePaths

BOOL CkSFtp_RenameFileOrDir(HCkSFtp cHandle, const char *oldPath, const char *newPath);

Renames a file or directory on the SFTP server.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_ResumeDownloadFileByName(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Resumes an SFTP download. The size of the localFilePath is checked and the download begins at the appropriate position in the remoteFilePath. If localFilePath is empty or non-existent, then this method is identical to DownloadFileByName. If the localFilePath is already fully downloaded, then no additional data is downloaded and the method will return true.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_ResumeUploadFileByName(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Resumes a file upload to the SFTP/SSH server. The size of the remoteFilePath is first checked to determine the starting offset for the upload. If remoteFilePath is empty or does not exist, this method is equivalent to UploadFileByName. If remoteFilePath is already fully uploaded (i.e. it's size is equal to localFilePath), then no additional bytes are uploaded and true is returned.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_SaveLastError(HCkSFtp cHandle, const char *filename);

Saves the last error information to an XML formatted file.

BOOL CkSFtp_SetCreateTime(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, SYSTEMTIME *createTime);

Sets the create date/time for a file on the server. The pathOrHandle may be a filepath or the handle of a currently open file. isHandle should be set to true if the pathOrHandle is a handle, otherwise set isHandle to false.

Note: Servers running version 3 or lower of the SFTP protocol do not support setting the create date/time.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_SetLastAccessTime(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, SYSTEMTIME *lastAccessTime);

Sets the last-access date/time for a file on the server. The pathOrHandle may be a filepath or the handle of a currently open file. isHandle should be set to true if the pathOrHandle is a handle, otherwise set isHandle to false.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_SetLastModifiedTime(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, SYSTEMTIME *lastModTime);

Sets the last-modified date/time for a file on the server. The pathOrHandle may be a filepath or the handle of a currently open file. isHandle should be set to true if the pathOrHandle is a handle, otherwise set isHandle to false.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_SetOwnerAndGroup(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, const char *owner, const char *group);

Sets the owner and group for a file on the server. The pathOrHandle may be a filepath or the handle of a currently open file. isHandle should be set to true if the pathOrHandle is a handle, otherwise set isHandle to false.

Note: Servers running version 3 or lower of the SFTP protocol do not support setting the owner and group.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_SetPermissions(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, int perm);

Sets the permissions for a file on the server. The pathOrHandle may be a filepath or the handle of a currently open file. isHandle should be set to true if the pathOrHandle is a handle, otherwise set isHandle to false.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_UnlockComponent(HCkSFtp cHandle, const char *unlockCode);

Unlocks the component. This must be called once prior to calling any other method. A fully-functional 30-day trial is automatically started when an arbitrary string is passed to this method. For example, passing "Hello", or "abc123" will unlock the component for the 1st thirty days after the initial install.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_UploadFile(HCkSFtp cHandle, const char *handle, const char *fromFilename);

Uploads a file from the local filesystem to the SFTP server. handle is a handle of a currently open file (obtained by calling the OpenFile method).

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_UploadFileByName(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Simplified method for uploading a file to the SFTP/SSH server.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileBytes(HCkSFtp cHandle, const char *handle, HCkByteData data);

Appends byte data to an open file. The handle is a file handle returned by the OpenFile method.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileBytes32(HCkSFtp cHandle, const char *handle, int offset, HCkByteData data);

Writes data to an open file at a specific offset from the beginning of the file. The handle is a file handle returned by the OpenFile method. The offset is an offset from the beginning of the file.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileBytes64(HCkSFtp cHandle, const char *handle, __int64 offset64, HCkByteData data);

Writes data to an open file at a specific offset from the beginning of the file. The handle is a file handle returned by the OpenFile method. The offset64 is an offset from the beginning of the file.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileBytes64s(HCkSFtp cHandle, const char *handle, const char *offset64, HCkByteData data);

Writes data to an open file at a specific offset from the beginning of the file. The handle is a file handle returned by the OpenFile method. The offset64 is an offset (in decimal string format) from the beginning of the file.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileText(HCkSFtp cHandle, const char *handle, const char *charset, const char *textData);

Appends character data to an open file. The handle is a file handle returned by the OpenFile method. charset is a character encoding and is typically set to values such as "ansi", "utf-8", "windows-1252", etc. A list of supported character encodings is found on this page: Supported Charsets.

Note: It is necessary to specify the character encoding because in many programming languages, strings are represented as Unicode (2 bytes/char) and in most cases one does not wish to write Unicode chars to a text file (although it is possible by setting charset = "Unicode").

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileText32(HCkSFtp cHandle, const char *handle, int offset32, const char *charset, const char *textData);

Writes character data to an open file at a specific offset from the beginning of the file. The handle is a file handle returned by the OpenFile method. charset is a character encoding and is typically set to values such as "ansi", "utf-8", "windows-1252", etc. A list of supported character encodings is found on this page: Supported Charsets.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileText64(HCkSFtp cHandle, const char *handle, __int64 offset64, const char *charset, const char *textData);

Writes character data to an open file at a specific offset from the beginning of the file. The handle is a file handle returned by the OpenFile method. charset is a character encoding and is typically set to values such as "ansi", "utf-8", "windows-1252", etc. A list of supported character encodings is found on this page: Supported Charsets.

Returns TRUE for success, FALSE for failure.

BOOL CkSFtp_WriteFileText64s(HCkSFtp cHandle, const char *handle, const char *offset64, const char *charset, const char *textData);

Writes character data to an open file at a specific offset from the beginning of the file. The handle is a file handle returned by the OpenFile method. The offset64 is an offset (in decimal string format) from the beginning of the file. charset is a character encoding and is typically set to values such as "ansi", "utf-8", "windows-1252", etc. A list of supported character encodings is found on this page: Supported Charsets.

Returns TRUE for success, FALSE for failure.

const char *CkSFtp_add64(HCkSFtp cHandle, const char *n1, const char *n2);

Convenience method for 64-bit addition. Allows for two 64-bit integers to be passed as decimal strings and returns the sum in a decimal sting.

const char *CkSFtp_clientIdentifier(HCkSFtp cHandle);

The client-identifier string to be used when connecting to an SSH/SFTP server. Defaults to "SSH-2.0-PuTTY_Local:_Jun_27_2008_16:28:58". (This string is used to mimic PuTTY because some servers are known to disconnect from clients with unknown client identifiers.)

const char *CkSFtp_disconnectReason(HCkSFtp cHandle);

If the SSH/SFTP server sent a DISCONNECT message when closing the connection, this property contains a descriptive string for the "reason code" as specified in RFC 4253.

const char *CkSFtp_filenameCharset(HCkSFtp cHandle);

Automatically set during the InitializeSftp method if the server sends a filename-charset name-value extension. Otherwise, may be set directly to the name of a charset, such as "utf-8", "iso-8859-1", "windows-1252", etc. ("ansi" is also a valid choice.) Incoming filenames are interpreted as utf-8 if no FilenameCharset is set. Outgoing filenames are sent using utf-8 by default. Otherwise, incoming and outgoing filenames use the charset specified by this property.

const char *CkSFtp_getFileGroup(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the group of a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

Note: Servers running the SFTP v3 protocol or lower do not have the ability to return a file's group name. Instead, the decimal GID of the file is returned.

const char *CkSFtp_getFileOwner(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the owner of a file. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

Note: Servers running the SFTP v3 protocol or lower do not have the ability to return a file's owner name. Instead, the decimal UID of the file is returned.

const char *CkSFtp_getFileSizeStr(HCkSFtp cHandle, const char *filenameOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the size in bytes (in decimal string form) of a file on the SSH server. filenameOrHandle may be a remote filepath or an open handle string as returned by OpenFile. If filenameOrHandle is a handle, then bIsHandle must be set to true, otherwise it should be false. If bFollowLinks is true, then symbolic links will be followed on the server.

Note: This method exists for environments that do not have 64-bit integer support. The Add64 method is provided for 64-bit addition, and other methods such as ReadFileBytes64s allow for 64-bit values to be passed as strings.

const char *CkSFtp_hostKeyFingerprint(HCkSFtp cHandle);

Set after connecting to an SSH/SFTP server. The format of the fingerprint looks like this: "ssh-rsa 1024 68:ff:d1:4e:6c:ff:d7:b0:d6:58:73:85:07:bc:2e:d5"

const char *CkSFtp_httpProxyAuthMethod(HCkSFtp cHandle);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "LOGIN" or "NTLM".

const char *CkSFtp_httpProxyHostname(HCkSFtp cHandle);

If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).

const char *CkSFtp_httpProxyPassword(HCkSFtp cHandle);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.

const char *CkSFtp_httpProxyUsername(HCkSFtp cHandle);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.

const char *CkSFtp_initializeFailReason(HCkSFtp cHandle);

The InitializeSftp method call opens a channel for the SFTP session. If the request to open a channel fails, this property contains a description of the reason for failure. (It contains descriptive text matching the InitializeFailCode property.)

const char *CkSFtp_lastErrorHtml(HCkSFtp cHandle);

Error information in HTML format for the last method called.

const char *CkSFtp_lastErrorText(HCkSFtp cHandle);

Error information in plain-text format for the last method called.

const char *CkSFtp_lastErrorXml(HCkSFtp cHandle);

Error information in XML format for the last method called.

const char *CkSFtp_openDir(HCkSFtp cHandle, const char *path);

Opens a directory for reading. To get a directory listing, first open the directory by calling this method, then call ReadDir to read the directory, and finally call CloseHandle to close the directory.

The SFTP protocol represents file names as strings. File names are assumed to use the slash ('/') character as a directory separator.

File names starting with a slash are "absolute", and are relative to the root of the file system. Names starting with any other character are relative to the user's default directory (home directory). Note that identifying the user is assumed to take place outside of this protocol.

Servers SHOULD interpret a path name component ".." as referring to the parent directory, and "." as referring to the current directory.

An empty path name is valid, and it refers to the user's default directory (usually the user's home directory).

Understanding SFTP Absolute FilePaths

const char *CkSFtp_openFile(HCkSFtp cHandle, const char *filename, const char *access, const char *createDisp);

Opens or creates a file on the remote system. Returns a handle which may be passed to methods for reading and/or writing the file. access should be one of the following strings: "readOnly", "writeOnly", or "readWrite". createDisposition is a comma-separated list of keywords to provide more control over how the file is opened or created. One of the following keywords must be present: "createNew", "createTruncate", "openExisting", "openOrCreate", or "truncateExisting". All other keywords are optional. The list of keywords and their meanings are shown here:

createNew
A new file is created; if the file already exists the method fails.

createTruncate
A new file is created; if the file already exists, it is opened and truncated.

openExisting
An existing file is opened. If the file does not exist the method fails.

openOrCreate
If the file exists, it is opened. If the file does not exist, it is created.

truncateExisting
An existing file is opened and truncated. If the file does not exist the method fails.

appendData
Data is always written at the end of the file. Data is not required to be appended atomically. This means that if multiple writers attempt to append data simultaneously, data from the first may be lost.

appendDataAtomic
Data is always written at the end of the file. Data MUST be written atomically so that there is no chance that multiple appenders can collide and result in data being lost.

textMode
Indicates that the server should treat the file as text and convert it to the canonical newline convention in use. When a file is opened with this flag, data is always appended to the end of the file. Servers MUST process multiple, parallel reads and writes correctly in this mode.

blockRead
The server MUST guarantee that no other handle has been opened with read access, and that no other handle will be opened with read access until the client closes the handle. (This MUST apply both to other clients and to other processes on the server.) In a nutshell, this opens the file in non-sharing mode.

blockWrite
The server MUST guarantee that no other handle has been opened with write access, and that no other handle will be opened with write access until the client closes the handle. (This MUST apply both to other clients and to other processes on the server.) In a nutshell, this opens the file in non-sharing mode.

blockDelete
The server MUST guarantee that the file itself is not deleted in any other way until the client closes the handle. No other client or process is allowed to open the file with delete access.

blockAdvisory
If set, the above "block" modes are advisory. In advisory mode, only other accesses that specify a "block" mode need be considered when determining whether the "block" can be granted, and the server need not prevent I/O operations that violate the block mode. The server MAY perform mandatory locking even if the blockAdvisory flag is set.

noFollow
If the final component of the path is a symlink, then the open MUST fail.

deleteOnClose
The file should be deleted when the last handle to it is closed. (The last handle may not be an sftp-handle.) This MAY be emulated by a server if the OS doesn't support it by deleting the file when this handle is closed.

accessAuditAlarmInfo
The client wishes the server to enable any privileges or extra capabilities that the user may have in to allow the reading and writing of AUDIT or ALARM access control entries.

accessBackup
The client wishes the server to enable any privileges or extra capabilities that the user may have in order to bypass normal access checks for the purpose of backing up or restoring files.

backupStream
This flag indicates that the client wishes to read or write a backup stream. A backup stream is a system dependent structured data stream that encodes all the information that must be preserved in order to restore the file from backup medium. The only well defined use for backup stream data read in this fashion is to write it to the same server to a file also opened using the backupStream flag. However, if the server has a well defined backup stream format, there may be other uses for this data outside the scope of this protocol.

Understanding SFTP Absolute FilePaths

const char *CkSFtp_readFileText(HCkSFtp cHandle, const char *handle, int numBytes, const char *charset);

This method is identical to ReadFileBytes except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

To read an entire file, one may call ReadFileText repeatedly until Eof(handle) returns true.

const char *CkSFtp_readFileText32(HCkSFtp cHandle, const char *handle, int offset32, int numBytes, const char *charset);

This method is identical to ReadFileBytes32 except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

const char *CkSFtp_readFileText64(HCkSFtp cHandle, const char *handle, __int64 offset64, int numBytes, const char *charset);

This method is identical to ReadFileBytes64 except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

const char *CkSFtp_readFileText64s(HCkSFtp cHandle, const char *handle, const char *offset64, int numBytes, const char *charset);

This method is identical to ReadFileBytes64s except for one thing: The bytes are interpreted according to the specified charset (i.e. the character encoding) and returned as a string. A list of supported charset values may be found on this page: Supported Charsets.

Note: If the charset is an encoding where a single character might be represented in multiple bytes (such as utf-8, Shift_JIS, etc.) then there is a risk that the very last character may be partially read. This is because the method specifies the number of bytes to read, not the number of characters. This is never a problem with character encodings that use a single byte per character, such as all of the iso-8859-* encodings, or the Windows-* encodings.

const char *CkSFtp_realPath(HCkSFtp cHandle, const char *originalPath, const char *composePath);

This method can be used to have the server canonicalize any given path name to an absolute path. This is useful for converting path names containing ".." components or relative pathnames without a leading slash into absolute paths. The absolute path is returned by this method.

originalPath is the first component of the path which the client wishes resolved into a absolute canonical path. This may be the entire path.

The composePath is a path which the client wishes the server to compose with the original path to form the new path. This field is optional and may be set to a zero-length string.

The server will take the originalPath and apply the composePath as a modification to it. composePath may be relative to originalPath or may be an absolute path, in which case originalPath will be discarded. The composePath may be zero length.

Note: Servers running SFTP v4 and below do not support composePath.

const char *CkSFtp_sessionLog(HCkSFtp cHandle);

Contains a log of the messages sent to/from the SFTP server. To enable session logging, set the KeepSessionLog property = true. Note: This property is not a filename -- it is a string property that contains the session log data.

const char *CkSFtp_socksHostname(HCkSFtp cHandle);

The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).

const char *CkSFtp_socksPassword(HCkSFtp cHandle);

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

const char *CkSFtp_socksUsername(HCkSFtp cHandle);

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

const char *CkSFtp_version(HCkSFtp cHandle);

The version of the SFTP component, such as "2.3.0".