SFtp C Reference Documentation

SFtp

Current Version: 11.5.0

Chilkat.SFtp

Transfer, list, manage, and synchronize files over SFTP.

Chilkat.SFtp is Chilkat's main class for secure file transfer over SSH. It provides SSH connection and authentication, SFTP subsystem initialization, uploads, downloads, directory listings, remote file management, file attributes, handle-based file access, recursive synchronization, bandwidth throttling, proxy support, host key fingerprinting, SSH algorithm controls, and detailed diagnostics.

SSH + SFTP setup

Connect to an SSH server, authenticate with password or key-based credentials, then initialize the SFTP subsystem before file operations.

Upload and download

Transfer files using simple path-based APIs, in-memory data, streams, or handle-based methods when lower-level control is needed.

Directory and file management

List directories, create and remove folders, rename files, delete files, inspect attributes, and work with remote paths.

Sync-tree operations

Upload or download directory trees and synchronize local and remote folder structures.

Security controls

Verify host keys, control accepted SSH algorithms, use private keys, and configure proxy or network settings when required.

Diagnostics and reliability

Use detailed error text, session logs, progress callbacks, bandwidth limits, and timeout settings to troubleshoot real-world server behavior.

Common pattern: Connect, authenticate, initialize SFTP, perform file operations using remote paths or handles, close any open handles, and disconnect. Use handle-based APIs for precise control, and synchronization methods for recursive folder transfers.

Create/Dispose

HCkSFtp instance = CkSFtp_Create();
// ...
CkSFtp_Dispose(instance);
HCkSFtp CkSFtp_Create(void);

Creates an instance of the HCkSFtp object and returns a handle ("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. Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkSFtp_Dispose.

Callback Functions

void CkSFtp_setAbortCheck(HCkSFtp cHandle, BOOL (*fnAbortCheck)(void));

Provides the opportunity for a method call to be aborted. If TRUE is returned, the operation in progress is aborted. Return FALSE to allow the current method call to continue. This callback function is called periodically based on the value of the HeartbeatMs property. (If HeartbeatMs is 0, then no callbacks are made.) As an example, to make 5 AbortCheck callbacks per second, set the HeartbeatMs property equal to 200.

void CkSFtp_setPercentDone(HCkSFtp cHandle, BOOL (*fnPercentDone)(int pctDone));

Provides the percentage completed for any method that involves network communications or time-consuming processing (assuming it is a method where a percentage completion can be measured). This callback is only called when it is possible to know a percentage completion, and when it makes sense to express the operation as a percentage completed. The pctDone argument will have a value from 1 to 100. For methods that complete very quickly, the number of PercentDone callbacks will vary, but the final callback should have a value of 100. For long running operations, no more than one callback per percentage point will occur (for example: 1, 2, 3, ... 98, 99, 100).

This callback counts as an AbortCheck callback, and takes the place of the AbortCheck event when it fires.

The return value indicates whether the method call should be aborted, or whether it should proceed. Return TRUE to abort, and FALSE to proceed.

void CkSFtp_setProgressInfo(HCkSFtp cHandle, void (*fnProgressInfo)(const char *name, const char *value));

This is a general callback that provides name/value information about what is happening at certain points during a method call. To see the information provided in ProgressInfo callbacks, if any, write code to handle this event and log the name/value pairs. Most are self-explanatory.

void CkSFtp_setTaskCompleted(HCkSFtp cHandle, void (*fnTaskCompleted)(HCkTask hTask));

Called in the background thread when an asynchronous task completes. (Note: When an async method is running, all callbacks are in the background thread.)

Properties

AbortCurrent
BOOL CkSFtp_getAbortCurrent(HCkSFtp cHandle);
void CkSFtp_putAbortCurrent(HCkSFtp cHandle, BOOL newVal);
Introduced in version 9.5.0.58

Set to TRUE to request that the currently running Chilkat operation abort. Both synchronous and asynchronous operations can be canceled; a synchronous call may be interrupted by setting this property from another thread.

When the abort is observed, the current method returns failure and Chilkat resets this property to FALSE. If no method is running, it is reset when the next method begins.

top
AuthFailReason
int CkSFtp_getAuthFailReason(HCkSFtp cHandle);
Introduced in version 9.5.0.52

Contains the result code from the most recent call to AuthenticatePw, AuthenticatePk, AuthenticatePwPk, or a corresponding secure-string authentication method.

ValueMeaning
1Transport failure: communication was lost, or a network read or write failed or timed out.
2Invalid private key: the key format, key type, or key contents are not suitable for public-key authentication.
3No mutually supported authentication method is available.
4SSH authentication protocol error: an unexpected or invalid message was received.
5The server rejected the supplied password or private key.
6The SSH session is already authenticated.
7The server requires a password change. See PasswordChangeRequested.
Read this property immediately after an authentication method fails. Also inspect LastErrorText for detailed diagnostics.
Lifetime: A later successful authentication does not necessarily reset this value. Consult it only immediately after an authentication method returns FALSE; do not use an older value to describe the current session.

top
BandwidthThrottleDown
int CkSFtp_getBandwidthThrottleDown(HCkSFtp cHandle);
void CkSFtp_putBandwidthThrottleDown(HCkSFtp cHandle, int newVal);
Introduced in version 9.5.0.49

Specifies the approximate maximum download rate, in bytes per second. The default is 0, which disables download throttling.

Bandwidth throttling is approximate. Actual throughput can vary because of network latency, SSH framing, buffering, and server behavior.

top
BandwidthThrottleUp
int CkSFtp_getBandwidthThrottleUp(HCkSFtp cHandle);
void CkSFtp_putBandwidthThrottleUp(HCkSFtp cHandle, int newVal);
Introduced in version 9.5.0.49

Specifies the approximate maximum upload rate, in bytes per second. The default is 0, which disables upload throttling.

Bandwidth throttling is approximate. Actual throughput can vary because of network latency, SSH framing, buffering, and server behavior.

More Information and Examples
top
ClientIdentifier
void CkSFtp_getClientIdentifier(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putClientIdentifier(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_clientIdentifier(HCkSFtp cHandle);

Specifies the SSH client-identification string sent when a connection is established. The default begins with SSH-2.0-Chilkat_ followed by the Chilkat version, for example SSH-2.0-Chilkat_11.6.0.

The value should begin with SSH-2.0-. A server may disconnect if the identification string is invalid.

top
ClientIpAddress
void CkSFtp_getClientIpAddress(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putClientIpAddress(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_clientIpAddress(HCkSFtp cHandle);

This property is normally left unset. Set it only on a multihomed computer when the application must bind the outgoing connection to a specific local network interface.

Specify a numeric IPv4 or IPv6 address, not a hostname. When the property is empty, the operating system automatically chooses the local address.

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

Specifies the maximum number of milliseconds allowed for the remote endpoint to accept the TCP connection.

This setting covers TCP connection establishment. After the socket is connected, receive and transfer inactivity are governed by IdleTimeoutMs and method-specific timeouts.

top
DebugLogFilePath
void CkSFtp_getDebugLogFilePath(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putDebugLogFilePath(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_debugLogFilePath(HCkSFtp cHandle);

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
DisconnectCode
int CkSFtp_getDisconnectCode(HCkSFtp cHandle);

Contains the RFC 4253 reason code from the most recent SSH DISCONNECT message received from the server. A value of 0 means no server-provided disconnect code is available.

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

See DisconnectReason for the server-provided descriptive text.

top
DisconnectReason
void CkSFtp_getDisconnectReason(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_disconnectReason(HCkSFtp cHandle);

Contains the descriptive text sent with the most recent server SSH DISCONNECT message. See DisconnectCode for the corresponding RFC 4253 reason code.

The text is supplied by the server and can be empty or generic. An ordinary TCP loss or a local disconnect does not necessarily produce an SSH disconnect reason.

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

Controls whether Chilkat caches remote file sizes and attributes requested by GetFileSize32, GetFileSize64, GetFileSizeStr, GetFileCreateTimeStr, GetFileLastAccessStr, GetFileLastModifiedStr, GetFileOwner, GetFileGroup, GetFilePermissions. The default is FALSE.

When enabled, requesting one attribute by filename causes the complete attribute set for that file to be cached. Later attribute requests for the same filename can be satisfied without another server round trip.

Caching applies only when a remote path is used, not when an open handle is used. Call ClearCache when remote metadata may have changed.

top
EnableCompression
BOOL CkSFtp_getEnableCompression(HCkSFtp cHandle);
void CkSFtp_putEnableCompression(HCkSFtp cHandle, BOOL newVal);
Introduced in version 9.5.0.56

Controls whether SSH compression may be negotiated. The default is FALSE.

Some older servers advertise compression but fail when it is enabled. If the server disconnects during or immediately after connection or authentication, try leaving this property FALSE.

top
EnableSecrets
BOOL CkSFtp_getEnableSecrets(HCkSFtp cHandle);
void CkSFtp_putEnableSecrets(HCkSFtp cHandle, BOOL newVal);
Introduced in version 11.5.0

Enables automatic resolution of secret specification strings from secure operating-system storage. The default is FALSE.

When TRUE, supported password properties and authentication methods may receive a value beginning with !! instead of a literal credential. Chilkat resolves the secret from Windows Credential Manager on Windows or Apple Keychain on macOS.

Secret specification format:

!![appName|]service[|domain]|username

This feature applies to HttpProxyPassword, SocksPassword, AuthenticatePw, and AuthenticatePwPk.

More Information and Examples
top
FilenameCharset
void CkSFtp_getFilenameCharset(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putFilenameCharset(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_filenameCharset(HCkSFtp cHandle);

Specifies the character encoding used for SFTP filenames. During InitializeSftp, Chilkat automatically sets this property when the server supplies a filename-charset extension.

When the property is empty, incoming and outgoing filenames use UTF-8. Otherwise, Chilkat uses the specified charset, such as utf-8, iso-8859-1, or windows-1252.

Use an explicit charset only when required by the server. UTF-8 is the normal SFTP filename encoding.

top
ForceCipher
void CkSFtp_getForceCipher(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putForceCipher(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_forceCipher(HCkSFtp cHandle);

Restricts SSH cipher negotiation to a single cipher. Leave this property empty to use Chilkat's normal preference order. For broader algorithm control, use SetAllowedAlgorithms.

Cipher nameFamily
chacha20-poly1305@openssh.comChaCha20-Poly1305 authenticated encryption
aes128-ctr, aes192-ctr, aes256-ctrAES in CTR mode
aes128-cbc, aes192-cbc, aes256-cbcAES in CBC mode
aes128-gcm@openssh.com, aes256-gcm@openssh.comAES-GCM authenticated encryption
twofish128-cbc, twofish256-cbcTwofish in CBC mode
blowfish-cbcBlowfish in CBC mode
If the server does not support the selected cipher, Connect fails.

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

Controls SFTP protocol-version negotiation. The default is TRUE, which forces use of SFTP v3 even when the server supports a newer version.

Set this property to FALSE before InitializeSftp when the application needs features introduced in SFTP v4, v5, or v6. After initialization, read ProtocolVersion to determine the negotiated version.

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

Specifies the interval, in milliseconds, between AbortCheck event callbacks during operations that support progress events. The default is 0, which disables periodic callbacks.

More Information and Examples
top
HostKeyAlg
void CkSFtp_getHostKeyAlg(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putHostKeyAlg(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_hostKeyAlg(HCkSFtp cHandle);

Specifies the preferred host-key algorithm used during SSH connection establishment. The default is DSS; set it to RSA only when required for compatibility with a particular server.

Normally this property should be left unchanged.

top
HostKeyFingerprint
void CkSFtp_getHostKeyFingerprint(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_hostKeyFingerprint(HCkSFtp cHandle);

Contains the connected server's host-key fingerprint in Chilkat's legacy MD5 format. The value is set after a successful SSH connection.

ssh-rsa 2048 68:ff:d1:4e:6c:ff:d7:b0:d6:58:73:85:07:bc:2e:d5
ssh-ed25519 256 c8:73:22:c7:82:aa:09:f1:1c:4e:99:8a:a0:62:a7:87
For new applications, use GetHostKeyFP with SHA256. Compare the fingerprint with a value obtained from a trusted source before sending credentials.
The value is cleared by Disconnect. Obtain and validate it while the SSH connection is active.

More Information and Examples
top
HttpProxyAuthMethod
void CkSFtp_getHttpProxyAuthMethod(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putHttpProxyAuthMethod(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_httpProxyAuthMethod(HCkSFtp cHandle);

Specifies the authentication method used by an HTTP proxy. Matching is case-insensitive.

ValueBehavior
emptyAutomatically negotiate a supported method.
BasicUse HTTP Basic authentication.
NTLMUse NTLM authentication.

top
HttpProxyDomain
void CkSFtp_getHttpProxyDomain(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putHttpProxyDomain(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_httpProxyDomain(HCkSFtp cHandle);

Specifies the optional Windows domain used for NTLM authentication with an HTTP proxy. This property is ignored for Basic authentication.

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

Specifies the hostname or numeric IP address of an HTTP proxy used to establish the SSH connection.

Set this property together with HttpProxyPort. A configured SOCKS proxy takes precedence when SocksVersion is 4 or 5.

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

Specifies the password used to authenticate with an HTTP proxy.

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

Specifies the HTTP proxy port. Common values include 8080 and 3128.

The proxy is used when HttpProxyHostname is nonempty, this property is nonzero, and SocksVersion is 0.

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

Specifies the username used to authenticate with an HTTP proxy.

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

Specifies the maximum period, in milliseconds, during which an SFTP operation may make no progress while sending or receiving data. The default is 30000 (30 seconds).

Set this property to 0 to allow an operation to wait indefinitely.

top
IncludeDotDirs
BOOL CkSFtp_getIncludeDotDirs(HCkSFtp cHandle);
void CkSFtp_putIncludeDotDirs(HCkSFtp cHandle, BOOL newVal);

Controls whether ReadDir and ReadDirListing include the special . and .. directory entries. The default is FALSE.

This property controls only the special directory entries . and ... It does not exclude ordinary hidden filenames such as .gitignore or .profile.

top
InitializeFailCode
int CkSFtp_getInitializeFailCode(HCkSFtp cHandle);

Contains the RFC 4254 channel-open failure code when InitializeSftp cannot open the SFTP session channel. The initial value is 0.

CodeSymbolic name
1SSH_OPEN_ADMINISTRATIVELY_PROHIBITED
2SSH_OPEN_CONNECT_FAILED
3SSH_OPEN_UNKNOWN_CHANNEL_TYPE
4SSH_OPEN_RESOURCE_SHORTAGE

top
InitializeFailReason
void CkSFtp_getInitializeFailReason(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_initializeFailReason(HCkSFtp cHandle);

Contains the descriptive text associated with InitializeFailCode when InitializeSftp cannot open the SFTP session channel. The text is supplied by the server and may be empty or generic.

top
IsConnected
BOOL CkSFtp_getIsConnected(HCkSFtp cHandle);

Returns TRUE when Chilkat's last known state indicates that the underlying SSH transport is connected. This means Connect succeeded; it does not mean authentication or InitializeSftp has completed.

This property is passive and does not perform network I/O. A silent network failure or a peer close may remain undetected until an operation reads from or writes to the socket.

To actively test whether the connection is still writable, call SendIgnore and check its return value. The server does not reply to an SSH IGNORE message.

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

Controls whether SSH and SFTP protocol traffic is accumulated in SessionLog. The default is FALSE.

Session logging is intended for diagnostics and grows as activity continues. Disable it when no longer needed and treat the resulting log as potentially sensitive.

top
LastErrorHtml
void CkSFtp_getLastErrorHtml(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_lastErrorHtml(HCkSFtp cHandle);

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
void CkSFtp_getLastErrorText(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_lastErrorText(HCkSFtp cHandle);

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
void CkSFtp_getLastErrorXml(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_lastErrorXml(HCkSFtp cHandle);

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
BOOL CkSFtp_getLastMethodSuccess(HCkSFtp cHandle);
void CkSFtp_putLastMethodSuccess(HCkSFtp cHandle, BOOL newVal);

Indicates the success or failure of the most recent method call: TRUE means success, FALSE means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
LastStatusCode
int CkSFtp_getLastStatusCode(HCkSFtp cHandle);
Introduced in version 9.5.0.85

Contains the numeric code from the most recently received SFTP SSH_FXP_STATUS response. This is not necessarily the status of the most recently called method. Methods that return a handle, attributes, or data can complete without receiving a new status response, leaving an older value unchanged. A successful method can therefore leave a previous nonzero status code in this property.

CodeSymbolic name
0SSH_FX_OK
1SSH_FX_EOF
2SSH_FX_NO_SUCH_FILE
3SSH_FX_PERMISSION_DENIED
4SSH_FX_FAILURE
5SSH_FX_BAD_MESSAGE
6SSH_FX_NO_CONNECTION
7SSH_FX_CONNECTION_LOST
8SSH_FX_OP_UNSUPPORTED
9SSH_FX_INVALID_HANDLE
10SSH_FX_NO_SUCH_PATH
11SSH_FX_FILE_ALREADY_EXISTS
12SSH_FX_WRITE_PROTECT
13SSH_FX_NO_MEDIA
14SSH_FX_NO_SPACE_ON_FILESYSTEM
15SSH_FX_QUOTA_EXCEEDED
16SSH_FX_UNKNOWN_PRINCIPAL
17SSH_FX_LOCK_CONFLICT
18SSH_FX_DIR_NOT_EMPTY
19SSH_FX_NOT_A_DIRECTORY
20SSH_FX_INVALID_FILENAME
21SSH_FX_LINK_LOOP
22SSH_FX_CANNOT_DELETE
23SSH_FX_INVALID_PARAMETER
24SSH_FX_FILE_IS_A_DIRECTORY
25SSH_FX_BYTE_RANGE_LOCK_CONFLICT
26SSH_FX_BYTE_RANGE_LOCK_REFUSED
27SSH_FX_DELETE_PENDING
28SSH_FX_FILE_CORRUPT
29SSH_FX_OWNER_INVALID
30SSH_FX_GROUP_INVALID
31SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK

See LastStatusMessage for the server-provided message text.

Use each method's documented return value as the primary success test. Read this property immediately after a relevant SFTP failure when the server status provides additional detail.

top
LastStatusMessage
void CkSFtp_getLastStatusMessage(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_lastStatusMessage(HCkSFtp cHandle);
Introduced in version 9.5.0.85

Contains the message text from the most recently received SFTP SSH_FXP_STATUS response. The wording is server-dependent.

This property can remain unchanged across later successful methods that do not receive a new status response. See LastStatusCode for the numeric code.

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

Specifies the maximum packet length used by the underlying SSH transport. The default is 32768 bytes.

Normally this property should remain unchanged.

top
PasswordChangeRequested
BOOL CkSFtp_getPasswordChangeRequested(HCkSFtp cHandle);

Indicates that the server rejected password authentication because the account password must be changed. This property is set by AuthenticatePw and AuthenticatePwPk.

When TRUE, call the authentication method again and pass the old and new passwords in this form:

|oldPassword|newPassword|

top
PercentDoneScale
int CkSFtp_getPercentDoneScale(HCkSFtp cHandle);
void CkSFtp_putPercentDoneScale(HCkSFtp cHandle, int newVal);
Introduced in version 9.5.0.49

Specifies the value representing 100% completion in PercentDone event callbacks. The default is 100.

For example, a scale of 1000 provides 0.1% granularity, so a callback value of 453 represents 45.3% complete. Values are clamped to the range 10 through 100000.

This property applies only in environments that support event callbacks and only to operations for which progress can be measured.

top
PreferIpv6
BOOL CkSFtp_getPreferIpv6(HCkSFtp cHandle);
void CkSFtp_putPreferIpv6(HCkSFtp cHandle, BOOL newVal);

Controls the preferred address family when DNS resolution returns both IPv4 and IPv6 addresses. The default is FALSE, which prefers IPv4. Set it to TRUE to prefer IPv6.

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

Controls whether path-based upload and download methods preserve source timestamps on the destination. The default is FALSE.

Last-modified time is preserved when supported by the negotiated SFTP version and destination filesystem. SFTP v3 represents these times with whole-second precision and does not provide a creation-time attribute; creation-time preservation requires a later protocol version and server support.

This property does not apply to low-level transfers performed by opening a remote handle, reading or writing the data, and then closing the handle.

top
ProtocolVersion
int CkSFtp_getProtocolVersion(HCkSFtp cHandle);

Contains the SFTP protocol version negotiated by InitializeSftp, normally a value from 3 through 6.

Chilkat and the server exchange their highest supported versions, and the session uses the lower compatible version. Features unavailable in older versions are identified throughout this reference documentation.

The initial value is 0. After a successful initialization, the negotiated value can remain populated after Disconnect and during a later connection before SFTP is initialized again. Do not use this property alone to determine whether an SFTP channel is currently open.

top
ReadDirMustMatch
void CkSFtp_getReadDirMustMatch(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putReadDirMustMatch(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_readDirMustMatch(HCkSFtp cHandle);
Introduced in version 9.5.0.53

Specifies a semicolon-separated list of filename patterns. When nonempty, ReadDir and ReadDirListing include only entries matching at least one pattern.

  • * matches zero or more characters.
  • Matching is case-insensitive.
  • ? and bracket expressions such as [0-9] are not wildcard operators.
  • Surrounding whitespace and empty entries between semicolons are ignored.
*.xml; *.txt; *.csv

top
ReadDirMustNotMatch
void CkSFtp_getReadDirMustNotMatch(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putReadDirMustNotMatch(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_readDirMustNotMatch(HCkSFtp cHandle);
Introduced in version 9.5.0.53

Specifies a semicolon-separated list of filename patterns. When nonempty, ReadDir and ReadDirListing exclude entries matching any pattern. Exclusion is applied after ReadDirMustMatch.

  • * matches zero or more characters.
  • Matching is case-insensitive.
  • ? and bracket expressions such as [0-9] are not wildcard operators.
  • Surrounding whitespace and empty entries between semicolons are ignored.
*.tmp; *.bak; *.log

top
ServerIdentifier
void CkSFtp_getServerIdentifier(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_serverIdentifier(HCkSFtp cHandle);
Introduced in version 9.5.0.71

Contains the SSH server-identification string received during connection establishment. For example:

SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.16
The last received identifier can remain populated after Disconnect. Use IsConnected to determine whether the SSH transport is currently connected.

top
SessionLog
void CkSFtp_getSessionLog(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_sessionLog(HCkSFtp cHandle);

Contains the in-memory SSH/SFTP protocol log. Enable logging by setting KeepSessionLog to TRUE.

This property contains log text, not a file path. Call ClearSessionLog to clear it.

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

Specifies the SOCKS proxy hostname or IPv4 address. This property is used only when SocksVersion is 4 or 5.

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

Specifies the SOCKS5 password when username/password authentication is required. SOCKS4 does not use a password, so this property is ignored when SocksVersion is 4.

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

Specifies the SOCKS proxy port. The default is 1080. This property is used only when SocksVersion is 4 or 5.

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

Specifies the SOCKS proxy username. For SOCKS4 it is sent as the user ID; for SOCKS5 it is used with SocksPassword for username/password authentication.

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

Selects whether and how a SOCKS proxy is used.

ValueBehavior
0Do not use a SOCKS proxy. This is the default.
4Connect through a SOCKS4 proxy.
5Connect through a SOCKS5 proxy.

top
SoRcvBuf
int CkSFtp_getSoRcvBuf(HCkSFtp cHandle);
void CkSFtp_putSoRcvBuf(HCkSFtp cHandle, int newVal);

Specifies the socket receive-buffer size. The default is 4194304 bytes. Normally this property should remain unchanged.

When download throughput is unexpectedly low, testing a larger value may help. Values should generally be multiples of 4096.

top
SoSndBuf
int CkSFtp_getSoSndBuf(HCkSFtp cHandle);
void CkSFtp_putSoSndBuf(HCkSFtp cHandle, int newVal);

Specifies the socket send-buffer size. The default is 262144 bytes. Normally this property should remain unchanged.

When upload throughput is unexpectedly low, testing values such as 524288 or 1048576 may help. Values should generally be multiples of 4096.

top
SyncCreateAllLocalDirs
BOOL CkSFtp_getSyncCreateAllLocalDirs(HCkSFtp cHandle);
void CkSFtp_putSyncCreateAllLocalDirs(HCkSFtp cHandle, BOOL newVal);
Introduced in version 9.5.0.76

Controls whether SyncTreeDownload creates empty remote directories locally. The default is TRUE.

When FALSE, a local directory is created only when it is needed to contain a downloaded file.

When TRUE, an empty remote directory is created locally even when no file beneath it is downloaded.

top
SyncDirectives
void CkSFtp_getSyncDirectives(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSyncDirectives(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_syncDirectives(HCkSFtp cHandle);
Introduced in version 9.5.0.58

Specifies comma-separated directives that modify SyncTreeUpload or SyncTreeDownload. The default is an empty string.

DirectiveEffect
UploadIgnoreLocalOpenFailuresDuring upload synchronization, skip local files that cannot be opened, such as files held with exclusive access by another process.

top
SyncMustMatch
void CkSFtp_getSyncMustMatch(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSyncMustMatch(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_syncMustMatch(HCkSFtp cHandle);

Specifies a semicolon-separated list of wildcard filename patterns. SyncTreeUpload and SyncTreeDownload transfer only files matching at least one pattern.

This filter applies to filenames, not directory names encountered while recursively traversing a tree.

*.xml;*.txt;*.csv
Use * to match zero or more characters. Separate multiple patterns with semicolons.

top
SyncMustMatchDir
void CkSFtp_getSyncMustMatchDir(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSyncMustMatchDir(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_syncMustMatchDir(HCkSFtp cHandle);
Introduced in version 9.5.0.76

Specifies a semicolon-separated list of wildcard directory-name patterns. SyncTreeUpload and SyncTreeDownload enter only directories matching at least one pattern.

xml;txt;data_*
Use * to match zero or more characters. Separate multiple patterns with semicolons.

top
SyncMustNotMatch
void CkSFtp_getSyncMustNotMatch(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSyncMustNotMatch(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_syncMustNotMatch(HCkSFtp cHandle);

Specifies a semicolon-separated list of wildcard filename patterns. SyncTreeUpload and SyncTreeDownload skip files matching any pattern.

This filter applies to filenames, not directory names encountered while recursively traversing a tree.

*.tmp;*.bak;*.log
Use * to match zero or more characters. Separate multiple patterns with semicolons.

top
SyncMustNotMatchDir
void CkSFtp_getSyncMustNotMatchDir(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putSyncMustNotMatchDir(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_syncMustNotMatchDir(HCkSFtp cHandle);
Introduced in version 9.5.0.76

Specifies a semicolon-separated list of wildcard directory-name patterns. SyncTreeUpload and SyncTreeDownload skip directories matching any pattern.

temp;cache;archive_*
Use * to match zero or more characters. Separate multiple patterns with semicolons.

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

Controls the TCP_NODELAY socket option. The default is FALSE. Set it to TRUE to disable the Nagle algorithm and reduce delays when many small packets are sent.

top
UncommonOptions
void CkSFtp_getUncommonOptions(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putUncommonOptions(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_uncommonOptions(HCkSFtp cHandle);
Introduced in version 9.5.0.73

Provides comma-separated compatibility, security, and synchronization options for uncommon scenarios. The default is an empty string and is appropriate for most applications.

KeywordEffect
ForceUserAuthRsaSha1Force legacy ssh-rsa/SHA-1 signatures for RSA user authentication. Set before connecting.
ProtectFromVpnOn Android, bypass an installed or active VPN.
NoSyncDownloadEmptyFilesPrevent empty files from being downloaded by SyncTreeDownload.
no-weak-mac-algsRemove weaker SHA-1, MD5, and RIPEMD-160 MAC algorithms from the offered list.
+ssh-hmac-etmRe-enable OpenSSH Encrypt-then-MAC algorithms disabled by default as a Terrapin mitigation.
+chacha20-poly1305@openssh.comRe-enable chacha20-poly1305@openssh.com, disabled by default as a Terrapin mitigation.

top
UploadChunkSize
int CkSFtp_getUploadChunkSize(HCkSFtp cHandle);
void CkSFtp_putUploadChunkSize(HCkSFtp cHandle, int newVal);

Specifies the chunk size, in bytes, used by UploadFile and UploadFileByName. The default is 32000.

If an upload fails because the local operating system aborts the connection, try a smaller value such as 4096. Smaller chunks can reduce throughput.

top
UserAuthBanner
void CkSFtp_getUserAuthBanner(HCkSFtp cHandle, HCkString retval);
void CkSFtp_putUserAuthBanner(HCkSFtp cHandle, const char *newVal);
const char *CkSFtp_userAuthBanner(HCkSFtp cHandle);
Introduced in version 9.5.0.88

Contains a user-authentication banner received from the server. Check this property after StartKeyboardAuth or another authentication attempt and display it to the user when appropriate.

When no banner is available, the property returns an empty string.

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

Controls the time zone used by date/time getters. When TRUE, returned values are expressed in UTC. When FALSE (the default), returned values are converted to the local time zone.

UtcMode = FALSE: Fri, 21 Nov 1997 09:55:06 -0600
UtcMode = TRUE:  Fri, 21 Nov 1997 15:55:06 GMT

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

When set to TRUE, all const char * arguments and return values are interpreted as UTF-8 strings. When set to FALSE, they are interpreted as ANSI strings.

In Chilkat v11.0.0 and later, the default value is TRUE. Before v11.0.0, it was FALSE.

top
VerboseLogging
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. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
void CkSFtp_getVersion(HCkSFtp cHandle, HCkString retval);
const char *CkSFtp_version(HCkSFtp cHandle);

Version of the component/library, such as "10.1.0"

More Information and Examples
top
XferByteCount
unsigned long CkSFtp_getXferByteCount(HCkSFtp cHandle);
Introduced in version 9.5.0.71

Contains the current transfer byte count for an upload or download in progress. An application can read this property while an asynchronous transfer is running.

For SyncTreeUpload and SyncTreeDownload, the value is cumulative across all files processed by the operation. Use XferByteCount64 when a 64-bit count is required.

top
XferByteCount64
__int64 CkSFtp_getXferByteCount64(HCkSFtp cHandle);
Introduced in version 9.5.0.71

Contains the current 64-bit transfer byte count for an upload or download in progress. An application can read this property while an asynchronous transfer is running.

For SyncTreeUpload and SyncTreeDownload, the value is cumulative across all files processed by the operation.

top

Methods

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

Authenticates the connected SSH session using public-key authentication. username identifies the server account, and privateKey must contain the corresponding private key. The matching public key must already be authorized for that account on the server.

Call Connect first. After a failure, inspect AuthFailReason and LastErrorText.

Returns TRUE for success, FALSE for failure.

top
AuthenticatePkAsync (1)
HCkTask CkSFtp_AuthenticatePkAsync(HCkSFtp cHandle, const char *username, HCkSshKey privateKey);

Creates an asynchronous task to call the AuthenticatePk method with the arguments provided.

Returns NULL on failure

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

Authenticates the connected SSH session using login and password.

1. Connect
2. AuthenticatePw or AuthenticatePk
3. InitializeSftp

If the server requests a password change, see PasswordChangeRequested. After a failure, inspect AuthFailReason and LastErrorText.

A rejected password does not necessarily close the SSH connection. The application may retry authentication on the same connected session. After a later success, an older AuthFailReason value can remain populated.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
AuthenticatePwAsync (1)
HCkTask CkSFtp_AuthenticatePwAsync(HCkSFtp cHandle, const char *login, const char *password);

Creates an asynchronous task to call the AuthenticatePw method with the arguments provided.

Returns NULL on failure

top
AuthenticatePwPk
BOOL CkSFtp_AuthenticatePwPk(HCkSFtp cHandle, const char *username, const char *password, HCkSshKey privateKey);

Authenticates with a server that requires both a password and a private key. username identifies the account, password supplies the password, and privateKey supplies the private key.

Most servers require either password or public-key authentication rather than both. After a failure, inspect AuthFailReason and LastErrorText.

Returns TRUE for success, FALSE for failure.

top
AuthenticatePwPkAsync (1)
HCkTask CkSFtp_AuthenticatePwPkAsync(HCkSFtp cHandle, const char *username, const char *password, HCkSshKey privateKey);

Creates an asynchronous task to call the AuthenticatePwPk method with the arguments provided.

Returns NULL on failure

top
AuthenticateSecPw
BOOL CkSFtp_AuthenticateSecPw(HCkSFtp cHandle, HCkSecureString login, HCkSecureString password);
Introduced in version 9.5.0.71

Works like AuthenticatePw, but receives login and password in SecureString objects.

Returns TRUE for success, FALSE for failure.

top
AuthenticateSecPwAsync (1)
HCkTask CkSFtp_AuthenticateSecPwAsync(HCkSFtp cHandle, HCkSecureString login, HCkSecureString password);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the AuthenticateSecPw method with the arguments provided.

Returns NULL on failure

top
AuthenticateSecPwPk
BOOL CkSFtp_AuthenticateSecPwPk(HCkSFtp cHandle, HCkSecureString username, HCkSecureString password, HCkSshKey privateKey);
Introduced in version 9.5.0.71

Works like AuthenticatePwPk, but receives username and password in SecureString objects. privateKey supplies the private key.

Returns TRUE for success, FALSE for failure.

top
AuthenticateSecPwPkAsync (1)
HCkTask CkSFtp_AuthenticateSecPwPkAsync(HCkSFtp cHandle, HCkSecureString username, HCkSecureString password, HCkSshKey privateKey);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the AuthenticateSecPwPk method with the arguments provided.

Returns NULL on failure

top
ClearAccumulateBuffer
void CkSFtp_ClearAccumulateBuffer(HCkSFtp cHandle);

Removes all bytes from AccumulateBuffer. Call this before starting a new sequence of AccumulateBytes operations.

top
ClearCache
void CkSFtp_ClearCache(HCkSFtp cHandle);

Clears the internal remote file-attribute cache used when EnableCache is TRUE.

More Information and Examples
top
ClearSessionLog
void CkSFtp_ClearSessionLog(HCkSFtp cHandle);

Clears the in-memory text stored in SessionLog.

More Information and Examples
top
CloseHandle
BOOL CkSFtp_CloseHandle(HCkSFtp cHandle, const char *handle);

Closes the remote file or directory handle specified by handle. The handle must have been returned by OpenFile or OpenDir.

Handles are specific to one initialized SFTP session. Close each handle exactly once. Closing an empty, invalid, or already-closed handle returns FALSE. A handle must never be reused after disconnecting or replacing the connection.

Returns TRUE for success, FALSE for failure.

top
CloseHandleAsync (1)
HCkTask CkSFtp_CloseHandleAsync(HCkSFtp cHandle, const char *handle);

Creates an asynchronous task to call the CloseHandle method with the arguments provided.

Returns NULL on failure

top
Connect
BOOL CkSFtp_Connect(HCkSFtp cHandle, const char *domainName, int port);

Establishes an SSH connection to domainName on TCP port port. The host may be a DNS name or numeric IPv4 or IPv6 address; SSH servers commonly listen on port 22.

A successful connection establishes the SSH transport only. Next call an authentication method, then call InitializeSftp.
1. Connect
2. AuthenticatePw, AuthenticatePk, or another authentication method
3. InitializeSftp
4. Perform SFTP operations

Supported negotiation algorithms include:

CategoryAlgorithms
Host keyssh-ed25519, rsa-sha2-256, rsa-sha2-512, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-rsa, ssh-dss
Key exchangecurve25519-sha256, curve25519-sha256@libssh.org, NIST ECDH, Diffie-Hellman group 1/14/16/18, and group-exchange SHA-1/SHA-256
CiphersAES CTR/CBC/GCM, Twofish CBC, Blowfish CBC, and optionally chacha20-poly1305@openssh.com
MACSHA-2, SHA-1, RIPEMD-160, MD5, and optionally OpenSSH Encrypt-then-MAC variants
Compressionnone, zlib, and zlib@openssh.com
Connection failures can occur before SSH negotiation because of firewalls, endpoint security, routing, network ACLs, proxy configuration, or server policy.
Calling while connected: A new successful Connect replaces the existing SSH connection. The previous SFTP subsystem and all handles from it are no longer usable. Authenticate and call InitializeSftp for the new connection.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
ConnectAsync (1)
HCkTask CkSFtp_ConnectAsync(HCkSFtp cHandle, const char *domainName, int port);

Creates an asynchronous task to call the Connect method with the arguments provided.

Returns NULL on failure

top
ConnectThroughSsh
BOOL CkSFtp_ConnectThroughSsh(HCkSFtp cHandle, HCkSsh sshConn, const char *hostname, int port);
Introduced in version 9.5.0.55

Connects to hostname on port through the already connected and authenticated Ssh object in sshConn.

application  →  first SSH server  →  destination SSH/SFTP server

After this method succeeds, authenticate separately with the destination server and call InitializeSftp. All destination traffic is carried through the first SSH connection.

Returns TRUE for success, FALSE for failure.

top
ConnectThroughSshAsync (1)
HCkTask CkSFtp_ConnectThroughSshAsync(HCkSFtp cHandle, HCkSsh sshConn, const char *hostname, int port);
Introduced in version 9.5.0.55

Creates an asynchronous task to call the ConnectThroughSsh method with the arguments provided.

Returns NULL on failure

top
ContinueKeyboardAuth
BOOL CkSFtp_ContinueKeyboardAuth(HCkSFtp cHandle, const char *response, HCkString outStr);
const char *CkSFtp_continueKeyboardAuth(HCkSFtp cHandle, const char *response);
Introduced in version 9.5.0.88

Continues keyboard-interactive authentication by submitting response for the prompts returned by StartKeyboardAuth.

For a single prompt, pass the response text directly. For multiple prompts, pass XML in this form:

<response>
  <response1>response to first prompt</response1>
  <response2>response to second prompt</response2>
  ...
</response>

The returned XML indicates authentication success, authentication failure, or another infoRequest containing additional prompts.

<success>success message</success>

<error>error message</error>

Returns TRUE for success, FALSE for failure.

top
ContinueKeyboardAuthAsync (1)
HCkTask CkSFtp_ContinueKeyboardAuthAsync(HCkSFtp cHandle, const char *response);
Introduced in version 9.5.0.88

Creates an asynchronous task to call the ContinueKeyboardAuth method with the arguments provided.

Returns NULL on failure

top
CopyFileAttr
BOOL CkSFtp_CopyFileAttr(HCkSFtp cHandle, const char *localFilename, const char *remoteFilename, BOOL isHandle);

Copies supported timestamps and attributes from the local file at localFilename to the remote item identified by remoteFilename.

Set isHandle to TRUE when remoteFilename contains an open SFTP handle; otherwise set it to FALSE for a remote path.

Negotiated SFTP versionAttributes copied
SFTP v3 and earlierLast-modified time and last-access time
SFTP v4 and v5Last-modified time, last-access time, and creation time
SFTP v6 and laterThe preceding timestamps plus read-only, hidden, archive, compressed, and encrypted flags
The remote server and filesystem determine whether all requested attributes can be applied. Last-access time may change when the server accesses the file, and compressed or encrypted flags may not have the same effect on every server.

Returns TRUE for success, FALSE for failure.

top
CopyFileAttrAsync (1)
HCkTask CkSFtp_CopyFileAttrAsync(HCkSFtp cHandle, const char *localFilename, const char *remoteFilename, BOOL isHandle);

Creates an asynchronous task to call the CopyFileAttr method with the arguments provided.

Returns NULL on failure

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

Creates the remote directory specified by path. Parent directories are not necessarily created automatically.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
CreateDirAsync (1)
HCkTask CkSFtp_CreateDirAsync(HCkSFtp cHandle, const char *path);

Creates an asynchronous task to call the CreateDir method with the arguments provided.

Returns NULL on failure

top
Disconnect
void CkSFtp_Disconnect(HCkSFtp cHandle);

Closes the current SSH/SFTP connection. All remote file and directory handles from that session become invalid and must not be reused.

The object remains reusable. A later session must call Connect, authenticate again, and call InitializeSftp before performing SFTP operations.

Some properties retain values from the previous session after disconnect, including the negotiated protocol version, server identifier, and last SFTP status. Treat these as historical values rather than evidence of a live session.
More Information and Examples
top
DownloadBd
BOOL CkSFtp_DownloadBd(HCkSFtp cHandle, const char *remoteFilePath, HCkBinData binData);
Introduced in version 9.5.0.62

Downloads the remote file at remoteFilePath and appends its bytes to binData.

Existing data in binData is preserved. Clear it first when replacement rather than append behavior is required.

Returns TRUE for success, FALSE for failure.

top
DownloadBdAsync (1)
HCkTask CkSFtp_DownloadBdAsync(HCkSFtp cHandle, const char *remoteFilePath, HCkBinData binData);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the DownloadBd method with the arguments provided.

Returns NULL on failure

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

Streams the remote file identified by handle to the local filesystem path toFilename. The handle must have been returned by OpenFile.

The transfer is streamed and is not limited by available memory. Close the remote handle when the download is complete.

This method downloads the entire remote file beginning at byte offset 0. It does not begin at the handle's current sequential read position.

Returns TRUE for success, FALSE for failure.

top
DownloadFileAsync (1)
HCkTask CkSFtp_DownloadFileAsync(HCkSFtp cHandle, const char *handle, const char *toFilename);

Creates an asynchronous task to call the DownloadFile method with the arguments provided.

Returns NULL on failure

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

Downloads the remote file at remoteFilePath to the local filesystem path localFilePath.

When PreserveDate is TRUE, Chilkat preserves the remote file's last-modified time.

An absolute remote path begins with / and is relative to the server filesystem root. A relative path is interpreted relative to the authenticated user's home directory.
If the local destination file exists, it is truncated before the download.

Returns TRUE for success, FALSE for failure.

top
DownloadFileByNameAsync (1)
HCkTask CkSFtp_DownloadFileByNameAsync(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Creates an asynchronous task to call the DownloadFileByName method with the arguments provided.

Returns NULL on failure

top
DownloadSb
BOOL CkSFtp_DownloadSb(HCkSFtp cHandle, const char *remoteFilePath, const char *charset, HCkStringBuilder sb);
Introduced in version 9.5.0.62

Downloads the remote file at remoteFilePath, decodes it using charset, and appends the text to sb.

Existing text in sb is preserved. Clear it first when replacement rather than append behavior is required.

Returns TRUE for success, FALSE for failure.

top
DownloadSbAsync (1)
HCkTask CkSFtp_DownloadSbAsync(HCkSFtp cHandle, const char *remoteFilePath, const char *charset, HCkStringBuilder sb);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the DownloadSb method with the arguments provided.

Returns NULL on failure

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

Returns TRUE when the most recent read for handle received the SFTP end-of-file status.

Reading exactly through the final byte does not set EOF immediately. The next read returns successfully with zero bytes, sets LastStatusCode to SSH_FX_EOF, and causes this method to return TRUE.

An empty, malformed, or already-closed handle can also cause this method to return TRUE. Use LastReadFailed and the read method's result to distinguish a normal EOF from a handle or read failure.
More Information and Examples
top
FileExists
int CkSFtp_FileExists(HCkSFtp cHandle, const char *remotePath, BOOL followLinks);
Introduced in version 9.5.0.67

Checks the remote item at remotePath. When followLinks is TRUE, a symbolic link is followed and the target type is returned.

Return valueMeaning
-1Unable to determine the result. Inspect LastErrorText.
0The path does not exist.
1A regular file exists.
2A directory exists.
3A symbolic link exists. This is possible only when followLinks is FALSE.
4A special filesystem entry exists.
5An entry of unknown type exists.
6A socket exists.
7A character device exists.
8A block device exists.
9A FIFO exists.
Positive values correspond to SFTP filesystem entry types. Some types are platform-dependent.
For a dangling symbolic link, followLinks = FALSE returns 3 for the link itself, while followLinks = TRUE returns 0 because the target does not exist.
top
FileExistsAsync (1)
HCkTask CkSFtp_FileExistsAsync(HCkSFtp cHandle, const char *remotePath, BOOL followLinks);
Introduced in version 9.5.0.67

Creates an asynchronous task to call the FileExists method with the arguments provided.

Returns NULL on failure

top
Fsync
BOOL CkSFtp_Fsync(HCkSFtp cHandle, const char *handle);
Introduced in version 9.5.0.71

Requests that the server flush pending data for the open file identified by handle to stable storage.

This method uses the OpenSSH fsync@openssh.com extension and succeeds only when the server supports that extension.

Returns TRUE for success, FALSE for failure.

top
FsyncAsync (1)
HCkTask CkSFtp_FsyncAsync(HCkSFtp cHandle, const char *handle);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the Fsync method with the arguments provided.

Returns NULL on failure

top
GetFileCreateTimeStr
BOOL CkSFtp_GetFileCreateTimeStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);
const char *CkSFtp_getFileCreateTimeStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's creation date and time. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

SFTP v3 and earlier do not provide a file creation time.

The result is an RFC 822 formatted string, for example Fri, 21 Nov 1997 09:55:06 -0600.

Returns TRUE for success, FALSE for failure.

top
GetFileCreateTimeStrAsync (1)
HCkTask CkSFtp_GetFileCreateTimeStrAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileCreateTimeStr method with the arguments provided.

Returns NULL on failure

top
GetFileGroup
BOOL CkSFtp_GetFileGroup(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);
const char *CkSFtp_getFileGroup(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's group ownership. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

With SFTP v3 and earlier, the result is the decimal numeric GID because textual group names are not supported.

Returns TRUE for success, FALSE for failure.

top
GetFileGroupAsync (1)
HCkTask CkSFtp_GetFileGroupAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileGroup method with the arguments provided.

Returns NULL on failure

top
GetFileLastAccessStr
BOOL CkSFtp_GetFileLastAccessStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);
const char *CkSFtp_getFileLastAccessStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's last-access date and time. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

The result is an RFC 822 formatted string, for example Fri, 21 Nov 1997 09:55:06 -0600.

Returns TRUE for success, FALSE for failure.

top
GetFileLastAccessStrAsync (1)
HCkTask CkSFtp_GetFileLastAccessStrAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileLastAccessStr method with the arguments provided.

Returns NULL on failure

top
GetFileLastModifiedStr
BOOL CkSFtp_GetFileLastModifiedStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);
const char *CkSFtp_getFileLastModifiedStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's last-modified date and time. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

The result is an RFC 822 formatted string, for example Fri, 21 Nov 1997 09:55:06 -0600.

Returns TRUE for success, FALSE for failure.

top
GetFileLastModifiedStrAsync (1)
HCkTask CkSFtp_GetFileLastModifiedStrAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileLastModifiedStr method with the arguments provided.

Returns NULL on failure

top
GetFileOwner
BOOL CkSFtp_GetFileOwner(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);
const char *CkSFtp_getFileOwner(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's owner. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

With SFTP v3 and earlier, the result is the decimal numeric UID because textual owner names are not supported.

Returns TRUE for success, FALSE for failure.

top
GetFileOwnerAsync (1)
HCkTask CkSFtp_GetFileOwnerAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileOwner method with the arguments provided.

Returns NULL on failure

top
GetFilePermissions
int CkSFtp_GetFilePermissions(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote item's complete POSIX mode value. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path. When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

The returned integer includes both the file-type bits and permission bits. For example:

Regular file, mode 0664: octal 0100664, decimal 33204
Regular file, mode 0600: octal 0100600, decimal 33152
Regular file, mode 0644: octal 0100644, decimal 33188

Mask with octal 07777 to obtain permission and special bits, or 0777 for only the traditional owner/group/other read, write, and execute bits. See SetPermissions to change the permissions.

More Information and Examples
top
GetFilePermissionsAsync (1)
HCkTask CkSFtp_GetFilePermissionsAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFilePermissions method with the arguments provided.

Returns NULL on failure

top
GetFileSize32
int CkSFtp_GetFileSize32(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's size in bytes as a 32-bit integer. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

Returns -1 when the size cannot be represented as a 32-bit integer. Use GetFileSize64 or GetFileSizeStr for large files.
More Information and Examples
top
GetFileSize32Async (1)
HCkTask CkSFtp_GetFileSize32Async(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileSize32 method with the arguments provided.

Returns NULL on failure

top
GetFileSize64
__int64 CkSFtp_GetFileSize64(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's size in bytes as a 64-bit integer. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

top
GetFileSize64Async (1)
HCkTask CkSFtp_GetFileSize64Async(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileSize64 method with the arguments provided.

Returns NULL on failure

top
GetFileSizeStr
BOOL CkSFtp_GetFileSizeStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle, HCkString outStr);
const char *CkSFtp_getFileSizeStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Returns the remote file's size in bytes as a decimal string. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
GetFileSizeStrAsync (1)
HCkTask CkSFtp_GetFileSizeStrAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);

Creates an asynchronous task to call the GetFileSizeStr method with the arguments provided.

Returns NULL on failure

top
GetHostKeyFP
BOOL CkSFtp_GetHostKeyFP(HCkSFtp cHandle, const char *hashAlg, BOOL includeKeyType, BOOL includeHashName, HCkString outStr);
const char *CkSFtp_getHostKeyFP(HCkSFtp cHandle, const char *hashAlg, BOOL includeKeyType, BOOL includeHashName);
Introduced in version 9.5.0.92

Returns the connected server's host-key fingerprint using hashAlg. Common choices include SHA256, SHA384, SHA512, SHA1, and MD5.

includeKeyTypeincludeHashNameExample format
TRUETRUEssh-rsa SHA256:L7sQgnpnoBwRoyIYXAFBs8SdSnwtyYmhXs1p/mQDK...
TRUEFALSEssh-rsa L7sQgnpnoBwRoyIYXAFBs8SdSnwtyYmhXs1p/mQDK...
FALSETRUESHA256:L7sQgnpnoBwRoyIYXAFBs8SdSnwtyYmhXs1p/mQDK...
FALSEFALSEL7sQgnpnoBwRoyIYXAFBs8SdSnwtyYmhXs1p/mQDK...
For server identity verification, compare a SHA-256 fingerprint with a value obtained from a trusted source before sending credentials.

Returns TRUE for success, FALSE for failure.

top
GetLastJsonData
void CkSFtp_GetLastJsonData(HCkSFtp cHandle, HCkJsonObject json);
Introduced in version 11.0.0

Populates json with supplemental details produced by the most recent method when such details are available. Many methods do not produce additional JSON information.

top
GetSyncedFiles
void CkSFtp_GetSyncedFiles(HCkSFtp cHandle, HCkStringTable strTab);
Introduced in version 10.0.0

Appends to strTab the relative paths processed by the most recent SyncTreeUpload or SyncTreeDownload operation.

For downloads, entries can include local directories that were created. Directory paths end with / so they can be distinguished from file paths.

Existing entries in strTab are preserved.
Clear strTab first when only the latest synchronization results are wanted. Downloaded directory entries are reported with a trailing /; uploaded directory entries are reported without one.
More Information and Examples
top
HardLink
BOOL CkSFtp_HardLink(HCkSFtp cHandle, const char *oldPath, const char *newPath);
Introduced in version 9.5.0.71

Creates a hard link from newPath to the existing remote file at oldPath.

This method uses the OpenSSH hardlink@openssh.com extension and succeeds only when the server supports that extension.
A successful hard link refers to the same underlying file. Modifying the existing file through either path changes the content observed through the other path.

Returns TRUE for success, FALSE for failure.

top
HardLinkAsync (1)
HCkTask CkSFtp_HardLinkAsync(HCkSFtp cHandle, const char *oldPath, const char *newPath);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the HardLink method with the arguments provided.

Returns NULL on failure

top
InitializeSftp
BOOL CkSFtp_InitializeSftp(HCkSFtp cHandle);

Opens the SFTP subsystem and negotiates the SFTP protocol version. Call this method after connecting and authenticating.

1. Connect
2. AuthenticatePw, AuthenticatePk, or another authentication method
3. InitializeSftp

After success, read ProtocolVersion to determine the negotiated SFTP version.

If opening the SFTP channel fails, inspect InitializeFailCode, InitializeFailReason, and LastErrorText.
Call this method only once for a given SSH connection. A second call on the same connection returns FALSE. After disconnecting or replacing the connection, authenticate the new connection and call this method again.

Returns TRUE for success, FALSE for failure.

top
InitializeSftpAsync (1)
HCkTask CkSFtp_InitializeSftpAsync(HCkSFtp cHandle);

Creates an asynchronous task to call the InitializeSftp method with the arguments provided.

Returns NULL on failure

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

Returns TRUE if the most recent read associated with handle failed; otherwise returns FALSE.

A normal end-of-file is not a read failure: the EOF read succeeds, returns zero bytes, and this method returns FALSE. For an empty, malformed, or already-closed handle, this method returns TRUE.

More Information and Examples
top
LastReadNumBytes
int CkSFtp_LastReadNumBytes(HCkSFtp cHandle, const char *handle);

Returns the number of bytes received by the most recent read associated with handle.

The initial value for a newly opened handle is 0. A normal EOF read and a failed read report 0.

More Information and Examples
top
LoadTaskCaller
BOOL CkSFtp_LoadTaskCaller(HCkSFtp cHandle, HCkTask task);
Introduced in version 9.5.0.80

Loads this object from the caller state associated with the completed asynchronous task.

Use the same object type that originally started the asynchronous operation.

Returns TRUE for success, FALSE for failure.

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

Opens the remote directory specified by path and returns a handle for reading its entries.

handle = OpenDir(path)
ReadDirListing(handle, dirObj)
CloseHandle(handle)

Remote paths use / as the separator. A path beginning with / is absolute; a relative path is interpreted relative to the authenticated user's home directory. An empty path refers to that default directory.

This method does not change a working directory. SFTP is not FTP and has no persistent current-directory command.

Returns TRUE for success, FALSE for failure.

top
OpenDirAsync (1)
HCkTask CkSFtp_OpenDirAsync(HCkSFtp cHandle, const char *path);

Creates an asynchronous task to call the OpenDir method with the arguments provided.

Returns NULL on failure

top
OpenFile
BOOL CkSFtp_OpenFile(HCkSFtp cHandle, const char *remotePath, const char *access, const char *createDisposition, HCkString outStr);
const char *CkSFtp_openFile(HCkSFtp cHandle, const char *remotePath, const char *access, const char *createDisposition);

Opens or creates the remote file at remotePath and returns a handle for subsequent read or write operations. Close the handle with CloseHandle when finished.

access must be readOnly, writeOnly, or readWrite.

createDisposition is a comma-separated list. It must contain exactly one primary disposition:

Primary dispositionBehavior
createNewCreate a new file; fail if it already exists.
createTruncateCreate a new file, or open and truncate an existing file.
openExistingOpen an existing file; fail if it does not exist.
openOrCreateOpen the file if it exists, otherwise create it.
truncateExistingOpen and truncate an existing file; fail if it does not exist.

Additional optional keywords are:

OptionBehavior
appendDataWrite at the end of the file. Appends are not guaranteed to be atomic.
appendDataAtomicAppend atomically so concurrent appenders do not collide. SFTP v5 or later.
textModeRequest server text-mode processing and canonical newline conversion. SFTP v5 or later.
blockReadRequest exclusive read access. SFTP v5 or later.
blockWriteRequest exclusive write access. SFTP v5 or later.
blockDeletePrevent deletion while the handle is open. SFTP v5 or later.
blockAdvisoryMake the requested block modes advisory. SFTP v5 or later.
noFollowFail if the final path component is a symbolic link. SFTP v5 or later.
deleteOnCloseRequest deletion when the last handle is closed. SFTP v5 or later.
accessAuditAlarmInfoRequest privileges needed to read or write AUDIT or ALARM ACL entries. SFTP v5 or later.
accessBackupRequest backup/restore privileges that may bypass normal access checks. SFTP v5 or later.
backupStreamRead or write a server-specific backup stream. SFTP v5 or later.
Options marked SFTP v5 or later require ForceV3 to be FALSE and a negotiated ProtocolVersion of at least 5.
An absolute remote path begins with /. A relative path is interpreted from the authenticated user's home directory. Some servers require a filename in the home directory to be written as ./filename.
Use only documented values: Some servers or Chilkat versions may tolerate an unknown access value, an unknown option, or conflicting primary dispositions, but the resulting behavior is unspecified. Supply one documented access value and exactly one primary disposition.
appendData forces writes to the end of the file, including explicit-offset writes. By itself it opens an existing file but does not create a missing file; combine it with an appropriate primary disposition when creation is required. Options defined for SFTP v5 or later must not be assumed to take effect when an older version is negotiated, even if the open request succeeds.

Returns TRUE for success, FALSE for failure.

top
OpenFileAsync (1)
HCkTask CkSFtp_OpenFileAsync(HCkSFtp cHandle, const char *remotePath, const char *access, const char *createDisposition);

Creates an asynchronous task to call the OpenFile method with the arguments provided.

Returns NULL on failure

top
ReadDirListing
BOOL CkSFtp_ReadDirListing(HCkSFtp cHandle, const char *handle, HCkSFtpDir dirObj);
Introduced in version 11.0.0

Reads all remaining directory entries from handle, which must have been returned by OpenDir, and stores them in dirObj. Entries are returned in server order; Chilkat does not sort the listing.

After end-of-directory has been reached, another call on the same handle returns TRUE, adds no entries, and sets LastStatusCode to SSH_FX_EOF.

This method does not clear dirObj. Use a new or cleared SFtpDir object when an empty result must replace an earlier listing. Close the directory handle when finished.

Returns TRUE for success, FALSE for failure.

top
ReadDirListingAsync (1)
HCkTask CkSFtp_ReadDirListingAsync(HCkSFtp cHandle, const char *handle, HCkSFtpDir dirObj);
Introduced in version 11.0.0

Creates an asynchronous task to call the ReadDirListing method with the arguments provided.

Returns NULL on failure

top
ReadFileBd
BOOL CkSFtp_ReadFileBd(HCkSFtp cHandle, const char *handle, int numBytes, HCkBinData bd);
Introduced in version 9.5.0.77

Reads up to numBytes bytes from the current position of the remote file identified by handle and appends them to bd. The handle must have been returned by OpenFile.

Fewer bytes can be read when end-of-file is reached. Repeat the call until Eof(handle) returns TRUE to read the entire file incrementally.

This method shares the handle's sequential read position with ReadFileBytes and ReadFileText. Existing bytes in bd are preserved.
More Information and Examples
top
ReadFileBdAsync (1)
HCkTask CkSFtp_ReadFileBdAsync(HCkSFtp cHandle, const char *handle, int numBytes, HCkBinData bd);
Introduced in version 9.5.0.77

Creates an asynchronous task to call the ReadFileBd method with the arguments provided.

Returns NULL on failure

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

Reads up to numBytes bytes from the current position of handle, decodes the bytes using charset, and returns the resulting text.

See Supported Charsets.

The requested size is measured in bytes, not characters. With a multibyte encoding such as UTF-8 or Shift_JIS, the final character can be split across calls. For robust streaming, read raw bytes and decode with application-maintained state.
Multibyte boundaries: Chilkat does not retain an incomplete multibyte character between calls. If numBytes ends in the middle of a UTF-8 sequence, the first returned string ends with the incomplete bytes and the next call begins with the remaining bytes. Choose byte counts that end on character boundaries, or read bytes and perform streaming decoding in the application.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
ReadFileTextAsync (1)
HCkTask CkSFtp_ReadFileTextAsync(HCkSFtp cHandle, const char *handle, int numBytes, const char *charset);

Creates an asynchronous task to call the ReadFileText method with the arguments provided.

Returns NULL on failure

top
ReadFileText32
BOOL CkSFtp_ReadFileText32(HCkSFtp cHandle, const char *handle, int offset, int numBytes, const char *charset, HCkString outStr);
const char *CkSFtp_readFileText32(HCkSFtp cHandle, const char *handle, int offset, int numBytes, const char *charset);

Reads up to numBytes bytes from handle at the 32-bit byte offset, decodes the bytes using charset, and returns the resulting text.

See Supported Charsets.

The requested size is measured in bytes, not characters. With a multibyte encoding such as UTF-8 or Shift_JIS, the final character can be split across calls. For robust streaming, read raw bytes and decode with application-maintained state.

Returns TRUE for success, FALSE for failure.

top
ReadFileText32Async (1)
HCkTask CkSFtp_ReadFileText32Async(HCkSFtp cHandle, const char *handle, int offset, int numBytes, const char *charset);

Creates an asynchronous task to call the ReadFileText32 method with the arguments provided.

Returns NULL on failure

top
ReadFileText64
BOOL CkSFtp_ReadFileText64(HCkSFtp cHandle, const char *handle, __int64 offset, int numBytes, const char *charset, HCkString outStr);
const char *CkSFtp_readFileText64(HCkSFtp cHandle, const char *handle, __int64 offset, int numBytes, const char *charset);

Reads up to numBytes bytes from handle at the 64-bit byte offset, decodes the bytes using charset, and returns the resulting text.

See Supported Charsets.

The requested size is measured in bytes, not characters. With a multibyte encoding such as UTF-8 or Shift_JIS, the final character can be split across calls. For robust streaming, read raw bytes and decode with application-maintained state.

Returns TRUE for success, FALSE for failure.

top
ReadFileText64Async (1)
HCkTask CkSFtp_ReadFileText64Async(HCkSFtp cHandle, const char *handle, __int64 offset, int numBytes, const char *charset);

Creates an asynchronous task to call the ReadFileText64 method with the arguments provided.

Returns NULL on failure

top
ReadFileText64s
BOOL CkSFtp_ReadFileText64s(HCkSFtp cHandle, const char *handle, const char *offset, int numBytes, const char *charset, HCkString outStr);
const char *CkSFtp_readFileText64s(HCkSFtp cHandle, const char *handle, const char *offset, int numBytes, const char *charset);

Reads up to numBytes bytes from handle at the byte offset supplied as decimal string offset, decodes the bytes using charset, and returns the resulting text.

See Supported Charsets.

The requested size is measured in bytes, not characters. With a multibyte encoding, the final character can be split across calls.

Returns TRUE for success, FALSE for failure.

top
ReadFileText64sAsync (1)
HCkTask CkSFtp_ReadFileText64sAsync(HCkSFtp cHandle, const char *handle, const char *offset, int numBytes, const char *charset);

Creates an asynchronous task to call the ReadFileText64s method with the arguments provided.

Returns NULL on failure

top
ReadLink
BOOL CkSFtp_ReadLink(HCkSFtp cHandle, const char *path, HCkString outStr);
const char *CkSFtp_readLink(HCkSFtp cHandle, const char *path);
Introduced in version 9.5.0.71

Returns the target path stored in the symbolic link at remote path.

The returned value is the target string stored in the link. It is not automatically canonicalized and can be relative, absolute, or refer to a nonexistent target.

Returns TRUE for success, FALSE for failure.

top
ReadLinkAsync (1)
HCkTask CkSFtp_ReadLinkAsync(HCkSFtp cHandle, const char *path);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the ReadLink method with the arguments provided.

Returns NULL on failure

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

Asks the server to canonicalize originalPath and returns the resulting absolute remote path.

For SFTP v5 or later, composePath may optionally modify or extend the original path; pass an empty string when no composition is needed. If composePath is absolute, it replaces originalPath.

SFTP v3 and v4 do not support path composition. On those versions, composePath is ignored and the method canonicalizes only originalPath.

Returns TRUE for success, FALSE for failure.

top
RealPathAsync (1)
HCkTask CkSFtp_RealPathAsync(HCkSFtp cHandle, const char *originalPath, const char *composePath);

Creates an asynchronous task to call the RealPath method with the arguments provided.

Returns NULL on failure

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

Deletes the remote directory specified by path.

Most SFTP servers require the directory to be empty before it can be removed.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
RemoveDirAsync (1)
HCkTask CkSFtp_RemoveDirAsync(HCkSFtp cHandle, const char *path);

Creates an asynchronous task to call the RemoveDir method with the arguments provided.

Returns NULL on failure

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

Deletes the remote file specified by filename.

Returns TRUE for success, FALSE for failure.

top
RemoveFileAsync (1)
HCkTask CkSFtp_RemoveFileAsync(HCkSFtp cHandle, const char *filename);

Creates an asynchronous task to call the RemoveFile method with the arguments provided.

Returns NULL on failure

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

Renames or moves a remote file or directory from oldPath to newPath.

oldPath: someDirA/filename
newPath: someDirB/abc/xyz/filename

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
RenameFileOrDirAsync (1)
HCkTask CkSFtp_RenameFileOrDirAsync(HCkSFtp cHandle, const char *oldPath, const char *newPath);

Creates an asynchronous task to call the RenameFileOrDir method with the arguments provided.

Returns NULL on failure

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

Resumes downloading remoteFilePath to the local filesystem path localFilePath. Chilkat uses only the existing local file size as the remote starting offset.

  • If the local file is missing or empty, a normal download is performed.
  • If it is smaller, the remaining remote bytes are appended after the existing local length.
  • If it is the same size or larger, the method treats the download as complete and does not truncate or verify the local content.
Important: The existing local bytes are not compared with the remote source. Before resuming, the application must ensure that the local file is the correct prefix of the remote file.

Returns TRUE for success, FALSE for failure.

top
ResumeDownloadFileByNameAsync (1)
HCkTask CkSFtp_ResumeDownloadFileByNameAsync(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Creates an asynchronous task to call the ResumeDownloadFileByName method with the arguments provided.

Returns NULL on failure

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

Resumes uploading the local file at localFilePath to remoteFilePath. Chilkat uses only the existing remote file size as the local starting offset.

  • If the remote file is missing or empty, a normal upload is performed.
  • If it is smaller, the remaining local bytes are appended after the existing remote length.
  • If it is the same size or larger, the method treats the upload as complete and does not truncate or verify the remote content.
Important: The existing remote bytes are not compared with the local source. Before resuming, the application must ensure that the remote file is the correct prefix of the local file.

Returns TRUE for success, FALSE for failure.

top
ResumeUploadFileByNameAsync (1)
HCkTask CkSFtp_ResumeUploadFileByNameAsync(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Creates an asynchronous task to call the ResumeUploadFileByName method with the arguments provided.

Returns NULL on failure

top
SendIgnore
BOOL CkSFtp_SendIgnore(HCkSFtp cHandle);
Introduced in version 9.5.0.66

Sends an SSH IGNORE message. No SFTP file handle or channel is required.

The server does not send a reply, but a successful send helps verify that the SSH connection is still writable.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
SendIgnoreAsync (1)
HCkTask CkSFtp_SendIgnoreAsync(HCkSFtp cHandle);
Introduced in version 9.5.0.66

Creates an asynchronous task to call the SendIgnore method with the arguments provided.

Returns NULL on failure

top
SetAllowedAlgorithms
BOOL CkSFtp_SetAllowedAlgorithms(HCkSFtp cHandle, HCkJsonObject json);
Introduced in version 9.5.0.99

Configures the exact set of SSH algorithms permitted for subsequent connections using the settings in json.

Call this method before Connect. The connection fails when no mutually supported algorithm remains in a required category.

Returns TRUE for success, FALSE for failure.

top
SetCreateDt
BOOL CkSFtp_SetCreateDt(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, HCkDateTime createDateTime);

Sets the remote file's creation date and time. pathOrHandle may contain a remote path or an open handle. Set isHandle to TRUE for a handle and FALSE for a path.

SFTP v3 and earlier do not support setting creation time.

createDateTime supplies the new value.

Returns TRUE for success, FALSE for failure.

top
SetCreateDtAsync (1)
HCkTask CkSFtp_SetCreateDtAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, HCkDateTime createDateTime);

Creates an asynchronous task to call the SetCreateDt method with the arguments provided.

Returns NULL on failure

top
SetCreateTimeStr
BOOL CkSFtp_SetCreateTimeStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, const char *dateTimeStr);

Sets the remote file's creation date and time. pathOrHandle may contain a remote path or an open handle. Set bIsHandle to TRUE for a handle and FALSE for a path.

Pass the value in dateTimeStr as an RFC 822 formatted string, for example Fri, 21 Nov 1997 09:55:06 -0600.

SFTP v3 and earlier do not support setting creation time.

Returns TRUE for success, FALSE for failure.

top
SetCreateTimeStrAsync (1)
HCkTask CkSFtp_SetCreateTimeStrAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, const char *dateTimeStr);

Creates an asynchronous task to call the SetCreateTimeStr method with the arguments provided.

Returns NULL on failure

top
SetLastAccessDt
BOOL CkSFtp_SetLastAccessDt(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, HCkDateTime accessDateTime);

Sets the remote file's last-access date and time. pathOrHandle may contain a remote path or an open handle. Set isHandle to TRUE for a handle and FALSE for a path.

accessDateTime supplies the new value.

Returns TRUE for success, FALSE for failure.

top
SetLastAccessDtAsync (1)
HCkTask CkSFtp_SetLastAccessDtAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, HCkDateTime accessDateTime);

Creates an asynchronous task to call the SetLastAccessDt method with the arguments provided.

Returns NULL on failure

top
SetLastAccessTimeStr
BOOL CkSFtp_SetLastAccessTimeStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, const char *dateTimeStr);

Sets the remote file's last-access date and time. pathOrHandle may contain a remote path or an open handle. Set bIsHandle to TRUE for a handle and FALSE for a path.

Pass the value in dateTimeStr as an RFC 822 formatted string, for example Fri, 21 Nov 1997 09:55:06 -0600.

Returns TRUE for success, FALSE for failure.

top
SetLastAccessTimeStrAsync (1)
HCkTask CkSFtp_SetLastAccessTimeStrAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, const char *dateTimeStr);

Creates an asynchronous task to call the SetLastAccessTimeStr method with the arguments provided.

Returns NULL on failure

top
SetLastModifiedDt
BOOL CkSFtp_SetLastModifiedDt(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, HCkDateTime modifiedDateTime);

Sets the remote file's last-modified date and time. pathOrHandle may contain a remote path or an open handle. Set isHandle to TRUE for a handle and FALSE for a path.

modifiedDateTime supplies the new value.

Returns TRUE for success, FALSE for failure.

top
SetLastModifiedDtAsync (1)
HCkTask CkSFtp_SetLastModifiedDtAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, HCkDateTime modifiedDateTime);

Creates an asynchronous task to call the SetLastModifiedDt method with the arguments provided.

Returns NULL on failure

top
SetLastModifiedTimeStr
BOOL CkSFtp_SetLastModifiedTimeStr(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, const char *dateTimeStr);

Sets the remote file's last-modified date and time. pathOrHandle may contain a remote path or an open handle. Set bIsHandle to TRUE for a handle and FALSE for a path.

Pass the value in dateTimeStr as an RFC 822 formatted string, for example Fri, 21 Nov 1997 09:55:06 -0600.

When SFTP v3 is negotiated, the stored timestamp has whole-second precision.

Returns TRUE for success, FALSE for failure.

top
SetLastModifiedTimeStrAsync (1)
HCkTask CkSFtp_SetLastModifiedTimeStrAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bIsHandle, const char *dateTimeStr);

Creates an asynchronous task to call the SetLastModifiedTimeStr method with the arguments provided.

Returns NULL on failure

top
SetOwnerAndGroup
BOOL CkSFtp_SetOwnerAndGroup(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, const char *owner, const char *group);

Sets the owner and group of the remote item identified by pathOrHandle. Set isHandle to TRUE for an open handle and FALSE for a remote path.

owner and group supply the new textual owner and group values.

SFTP v3 and earlier do not support textual owner and group names.

Returns TRUE for success, FALSE for failure.

top
SetOwnerAndGroupAsync (1)
HCkTask CkSFtp_SetOwnerAndGroupAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, const char *owner, const char *group);

Creates an asynchronous task to call the SetOwnerAndGroup method with the arguments provided.

Returns NULL on failure

top
SetPermissions
BOOL CkSFtp_SetPermissions(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, int permissions);

Sets the POSIX permission bits for the remote item identified by pathOrHandle. Set isHandle to TRUE for an open handle and FALSE for a remote path.

Pass the permission bits, not the file-type bits. In languages supporting octal integer literals, common values include 0600, 0644, and 0755. Their decimal equivalents are 384, 420, and 493.

After setting permissions, GetFilePermissions returns the complete mode, including the file-type bits. For example, setting 0644 on a regular file can subsequently return 0100644.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
SetPermissionsAsync (1)
HCkTask CkSFtp_SetPermissionsAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL isHandle, int permissions);

Creates an asynchronous task to call the SetPermissions method with the arguments provided.

Returns NULL on failure

top
StartKeyboardAuth
BOOL CkSFtp_StartKeyboardAuth(HCkSFtp cHandle, const char *login, HCkString outStr);
const char *CkSFtp_startKeyboardAuth(HCkSFtp cHandle, const char *login);
Introduced in version 9.5.0.88

Begins keyboard-interactive authentication for login and returns XML describing the server's prompts.

<infoRequest numPrompts="N">
  <name>name_string</name>
  <instruction>instruction_string</instruction>
  <prompt1 echo="1_or_0">prompt_string</prompt1>
  ...
  <promptN echo="1_or_0">prompt_string</promptN>
</infoRequest>

The echo attribute indicates whether the response may be displayed while entered. A value of 0 normally identifies secret input such as a password.

If authentication immediately succeeds or fails, the result has one of these forms:

<success>success message</success>

<error>error message</error>

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
StartKeyboardAuthAsync (1)
HCkTask CkSFtp_StartKeyboardAuthAsync(HCkSFtp cHandle, const char *login);
Introduced in version 9.5.0.88

Creates an asynchronous task to call the StartKeyboardAuth method with the arguments provided.

Returns NULL on failure

top
SymLink
BOOL CkSFtp_SymLink(HCkSFtp cHandle, const char *oldPath, const char *newPath);
Introduced in version 9.5.0.71

Creates a symbolic link on the server. oldPath identifies the link target and newPath identifies the new symbolic-link path.

The server's SFTP implementation determines path interpretation and whether symbolic links are permitted.

Returns TRUE for success, FALSE for failure.

top
SymLinkAsync (1)
HCkTask CkSFtp_SymLinkAsync(HCkSFtp cHandle, const char *oldPath, const char *newPath);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the SymLink method with the arguments provided.

Returns NULL on failure

top
SyncTreeDownload
BOOL CkSFtp_SyncTreeDownload(HCkSFtp cHandle, const char *remoteRoot, const char *localRoot, int mode, BOOL recurse);

Synchronizes files from the remote directory remoteRoot to the local filesystem directory localRoot.

ModeBehavior
0Download all files.
1Download files that do not exist locally.
2Download files that are newer remotely or missing locally.
3Download only files that are newer remotely; do not download missing local files.
5Download files that are missing locally or differ in size.
6Mode 5 plus files that are newer remotely.
99Do not download; delete remote files that do not exist locally.

Set recurse to TRUE to descend into subdirectories. An absolute remote path begins with /; a relative path is interpreted from the authenticated user's home directory.

Use GetSyncedFiles after the operation to retrieve the relative paths that were downloaded or created.

With SyncCreateAllLocalDirs set to TRUE, mode 0 creates empty remote directories locally. Mode 1 downloads only missing local files and preserves existing local files. Mode 99 deletes files from the remote tree that are absent locally; it does not delete extra local files.

Returns TRUE for success, FALSE for failure.

top
SyncTreeDownloadAsync (1)
HCkTask CkSFtp_SyncTreeDownloadAsync(HCkSFtp cHandle, const char *remoteRoot, const char *localRoot, int mode, BOOL recurse);

Creates an asynchronous task to call the SyncTreeDownload method with the arguments provided.

Returns NULL on failure

top
SyncTreeUpload
BOOL CkSFtp_SyncTreeUpload(HCkSFtp cHandle, const char *localBaseDir, const char *remoteBaseDir, int mode, BOOL bRecurse);

Synchronizes files from the local filesystem directory localBaseDir to the remote directory remoteBaseDir.

ModeBehavior
0Upload all files.
1Upload files that do not exist remotely.
2Upload files that are newer locally or missing remotely.
3Upload only files that are newer locally; do not upload missing remote files.
4Upload files that are missing remotely or differ in size.
5Mode 4 plus files that are newer locally.

Set bRecurse to TRUE to descend into subdirectories. An absolute remote path begins with /; a relative path is interpreted from the authenticated user's home directory.

Use GetSyncedFiles after the operation to retrieve the relative paths that were uploaded.

Mode 0 also creates empty remote directories. Mode 1 uploads only missing files and does not replace an existing remote file merely because the local file is newer; use mode 2 for missing-or-newer behavior. The filename and directory filters are applied during recursive traversal.

Returns TRUE for success, FALSE for failure.

top
SyncTreeUploadAsync (1)
HCkTask CkSFtp_SyncTreeUploadAsync(HCkSFtp cHandle, const char *localBaseDir, const char *remoteBaseDir, int mode, BOOL bRecurse);

Creates an asynchronous task to call the SyncTreeUpload method with the arguments provided.

Returns NULL on failure

top
UploadBd
BOOL CkSFtp_UploadBd(HCkSFtp cHandle, HCkBinData binData, const char *remoteFilePath);
Introduced in version 9.5.0.62

Uploads all bytes in binData to the remote file at remoteFilePath.

If the destination exists, it is truncated before the bytes are uploaded.

Returns TRUE for success, FALSE for failure.

top
UploadBdAsync (1)
HCkTask CkSFtp_UploadBdAsync(HCkSFtp cHandle, HCkBinData binData, const char *remoteFilePath);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the UploadBd method with the arguments provided.

Returns NULL on failure

top
UploadFile
BOOL CkSFtp_UploadFile(HCkSFtp cHandle, const char *handle, const char *fromLocalFilePath);

Streams the local filesystem file at fromLocalFilePath to the remote file identified by handle. The handle must have been returned by OpenFile.

Close the remote handle when the upload is complete.

The upload begins at the handle's current sequential write position. Existing bytes before that position are preserved unless the file was truncated when opened.

Returns TRUE for success, FALSE for failure.

top
UploadFileAsync (1)
HCkTask CkSFtp_UploadFileAsync(HCkSFtp cHandle, const char *handle, const char *fromLocalFilePath);

Creates an asynchronous task to call the UploadFile method with the arguments provided.

Returns NULL on failure

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

Uploads the local filesystem file at localFilePath to remoteFilePath.

When PreserveDate is TRUE, Chilkat preserves the local file's last-modified time on the remote file.

An absolute remote path begins with / and is relative to the server filesystem root. A relative path is interpreted relative to the authenticated user's home directory.
If the destination exists, it is truncated before the upload. A zero-byte local file creates or truncates the remote file to zero bytes. Missing remote parent directories are not created automatically.

Returns TRUE for success, FALSE for failure.

top
UploadFileByNameAsync (1)
HCkTask CkSFtp_UploadFileByNameAsync(HCkSFtp cHandle, const char *remoteFilePath, const char *localFilePath);

Creates an asynchronous task to call the UploadFileByName method with the arguments provided.

Returns NULL on failure

top
UploadSb
BOOL CkSFtp_UploadSb(HCkSFtp cHandle, HCkStringBuilder sb, const char *remoteFilePath, const char *charset, BOOL includeBom);
Introduced in version 9.5.0.62

Encodes the text in sb using charset and uploads it to remoteFilePath.

Set includeBom to TRUE to prepend a byte-order mark when the selected encoding supports one.

If the destination exists, it is truncated before the text is uploaded. For utf-8, setting includeBom to TRUE prepends the three bytes EF BB BF; setting it to FALSE omits them.

Returns TRUE for success, FALSE for failure.

top
UploadSbAsync (1)
HCkTask CkSFtp_UploadSbAsync(HCkSFtp cHandle, HCkStringBuilder sb, const char *remoteFilePath, const char *charset, BOOL includeBom);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the UploadSb method with the arguments provided.

Returns NULL on failure

top
WriteFileBd
BOOL CkSFtp_WriteFileBd(HCkSFtp cHandle, const char *handle, HCkBinData bd);
Introduced in version 9.5.0.77

Appends all bytes in bd to the remote file identified by handle. The handle must have been returned by OpenFile.

Returns TRUE for success, FALSE for failure.

top
WriteFileBdAsync (1)
HCkTask CkSFtp_WriteFileBdAsync(HCkSFtp cHandle, const char *handle, HCkBinData bd);
Introduced in version 9.5.0.77

Creates an asynchronous task to call the WriteFileBd method with the arguments provided.

Returns NULL on failure

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

Encodes textData using charset and writes the resulting bytes at the current sequential write position for handle.

The position is maintained by Chilkat for the handle. Opening an existing file with openOrCreate positions sequential writes at the current end of the file. An explicit-offset write can change the position used by the next sequential write. When the file was opened with appendData, writes are forced to the end.

See Supported Charsets.

No byte-order mark or line ending is added unless it is present in the supplied text or produced by the selected encoding.

Returns TRUE for success, FALSE for failure.

More Information and Examples
top
WriteFileTextAsync (1)
HCkTask CkSFtp_WriteFileTextAsync(HCkSFtp cHandle, const char *handle, const char *charset, const char *textData);

Creates an asynchronous task to call the WriteFileText method with the arguments provided.

Returns NULL on failure

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

Encodes textData using charset and writes the resulting bytes to handle at the 32-bit byte offset offset32.

After a successful explicit-offset write, the next sequential write begins immediately after the bytes written by this call. If the file was opened with appendData, the server appends and the explicit offset does not control placement.

See Supported Charsets.

offset32 must be nonnegative. A negative value can be interpreted as a very large unsigned offset. Writing beyond end-of-file can create a sparse file; whether the gap is sparse is determined by the server filesystem.
No byte-order mark or line ending is added unless it is present in the supplied text or produced by the selected encoding.

Returns TRUE for success, FALSE for failure.

top
WriteFileText32Async (1)
HCkTask CkSFtp_WriteFileText32Async(HCkSFtp cHandle, const char *handle, int offset32, const char *charset, const char *textData);

Creates an asynchronous task to call the WriteFileText32 method with the arguments provided.

Returns NULL on failure

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

Encodes textData using charset and writes the resulting bytes to handle at the 64-bit byte offset offset64.

See Supported Charsets.

No byte-order mark or line ending is added unless it is present in the supplied text or produced by the selected encoding.

Returns TRUE for success, FALSE for failure.

top
WriteFileText64Async (1)
HCkTask CkSFtp_WriteFileText64Async(HCkSFtp cHandle, const char *handle, __int64 offset64, const char *charset, const char *textData);

Creates an asynchronous task to call the WriteFileText64 method with the arguments provided.

Returns NULL on failure

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

Encodes textData using charset and writes the resulting bytes to handle at the byte offset supplied as decimal string offset64.

See Supported Charsets.

No byte-order mark or line ending is added unless it is present in the supplied text or produced by the selected encoding.

Returns TRUE for success, FALSE for failure.

top
WriteFileText64sAsync (1)
HCkTask CkSFtp_WriteFileText64sAsync(HCkSFtp cHandle, const char *handle, const char *offset64, const char *charset, const char *textData);

Creates an asynchronous task to call the WriteFileText64s method with the arguments provided.

Returns NULL on failure

top

Deprecated

AccumulateBytes
int CkSFtp_AccumulateBytes(HCkSFtp cHandle, const char *handle, int maxBytes);
This method is deprecated.

Reads up to maxBytes bytes from the remote file identified by handle and appends them to AccumulateBuffer. The handle must have been returned by OpenFile.

Returns the number of bytes appended. Fewer bytes can be returned when end-of-file is reached. Returns -1 if an error occurs.

top
AccumulateBytesAsync (1)
HCkTask CkSFtp_AccumulateBytesAsync(HCkSFtp cHandle, const char *handle, int maxBytes);
This method is deprecated.

Creates an asynchronous task to call the AccumulateBytes method with the arguments provided.

Returns NULL on failure

top
Add64
BOOL CkSFtp_Add64(HCkSFtp cHandle, const char *n1, const char *n2, HCkString outStr);
const char *CkSFtp_add64(HCkSFtp cHandle, const char *n1, const char *n2);
This method is deprecated.

Adds two 64-bit integers supplied as decimal strings and returns the sum as a decimal string.

n1 and n2 are useful in environments that cannot represent 64-bit integer values directly.

Returns TRUE for success, FALSE for failure.

top
GetFileCreateDt
HCkDateTime CkSFtp_GetFileCreateDt(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);
This method is deprecated.

Deprecated: Use GetFileCreateTimeStr instead.

Returns the remote file's creation date and time. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

SFTP v3 and earlier do not provide a file creation time.

Returns NULL on failure

top
GetFileCreateDtAsync (1) (2)
HCkTask CkSFtp_GetFileCreateDtAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);
This method is deprecated.

Creates an asynchronous task to call the GetFileCreateDt method with the arguments provided.

Returns NULL on failure

top
GetFileLastAccessDt
HCkDateTime CkSFtp_GetFileLastAccessDt(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);
This method is deprecated.

Deprecated: Use GetFileLastAccessStr instead.

Returns the remote file's last-access date and time. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

Returns NULL on failure

top
GetFileLastAccessDtAsync (1) (2)
HCkTask CkSFtp_GetFileLastAccessDtAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);
This method is deprecated.

Creates an asynchronous task to call the GetFileLastAccessDt method with the arguments provided.

Returns NULL on failure

top
GetFileLastModifiedDt
HCkDateTime CkSFtp_GetFileLastModifiedDt(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);
This method is deprecated.

Deprecated: Use GetFileLastModifiedStr instead.

Returns the remote file's last-modified date and time. pathOrHandle may contain a remote path or a handle returned by OpenFile. Set bIsHandle to TRUE for a handle and FALSE for a path.

When bFollowLinks is TRUE, the server follows a symbolic link and returns metadata for its target.

Returns NULL on failure

top
GetFileLastModifiedDtAsync (1) (2)
HCkTask CkSFtp_GetFileLastModifiedDtAsync(HCkSFtp cHandle, const char *pathOrHandle, BOOL bFollowLinks, BOOL bIsHandle);
This method is deprecated.

Creates an asynchronous task to call the GetFileLastModifiedDt method with the arguments provided.

Returns NULL on failure

top
LastJsonData
HCkJsonObject CkSFtp_LastJsonData(HCkSFtp cHandle);
Introduced in version 9.5.0.79
This method is deprecated.

Deprecated: Use GetLastJsonData instead.

Returns a JsonObject containing supplemental details produced by the most recent method when such details are available. Many methods do not produce additional JSON information.

Returns NULL on failure

top
ReadDir
HCkSFtpDir CkSFtp_ReadDir(HCkSFtp cHandle, const char *handle);
This method is deprecated and replaced by ReadDirListing

Deprecated: Use ReadDirListing instead.

Reads directory entries from the handle returned by OpenDir and returns an SFtpDir object containing the listing.

Returns NULL on failure

top
ReadDirAsync (1) (2)
HCkTask CkSFtp_ReadDirAsync(HCkSFtp cHandle, const char *handle);
This method is deprecated and replaced by ReadDirListing

Creates an asynchronous task to call the ReadDir method with the arguments provided.

Returns NULL on failure

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

Reads up to numBytes bytes from the current position of the remote file identified by handle. The handle must have been returned by OpenFile.

Fewer bytes can be returned when end-of-file is reached. To read the entire file incrementally, repeat the call until Eof(handle) returns TRUE.

This is a sequential read and advances the handle's maintained read position by the number of bytes returned. For predictable positioning, do not mix sequential reads with explicit-offset reads on the same handle.

Returns TRUE for success, FALSE for failure.

top
ReadFileBytesAsync Deprecated (1)
HCkTask CkSFtp_ReadFileBytesAsync(HCkSFtp cHandle, const char *handle, int numBytes);

Creates an asynchronous task to call the ReadFileBytes method with the arguments provided.

Returns NULL on failure

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

Reads up to numBytes bytes from handle, beginning at the 32-bit byte offset from the start of the file.

The offset is ignored when the file was opened with textMode. Use ReadFileBytes64 or ReadFileBytes64s for offsets outside the 32-bit range.

The read updates the per-handle read status and interacts with the handle's maintained sequential position. Do not rely on the next sequential read position after mixing explicit-offset and sequential reads; use one positioning style consistently for a handle.

Returns TRUE for success, FALSE for failure.

top
ReadFileBytes32Async Deprecated (1)
HCkTask CkSFtp_ReadFileBytes32Async(HCkSFtp cHandle, const char *handle, int offset, int numBytes);

Creates an asynchronous task to call the ReadFileBytes32 method with the arguments provided.

Returns NULL on failure

top
ReadFileBytes64 Deprecated
BOOL CkSFtp_ReadFileBytes64(HCkSFtp cHandle, const char *handle, __int64 offset, int numBytes, HCkByteData outBytes);

Reads up to numBytes bytes from handle, beginning at the 64-bit byte offset from the start of the file.

The offset is ignored when the file was opened with textMode. Fewer bytes can be returned when end-of-file is reached.

Returns TRUE for success, FALSE for failure.

top
ReadFileBytes64Async Deprecated (1)
HCkTask CkSFtp_ReadFileBytes64Async(HCkSFtp cHandle, const char *handle, __int64 offset, int numBytes);

Creates an asynchronous task to call the ReadFileBytes64 method with the arguments provided.

Returns NULL on failure

top
ReadFileBytes64s Deprecated
BOOL CkSFtp_ReadFileBytes64s(HCkSFtp cHandle, const char *handle, const char *offset, int numBytes, HCkByteData outBytes);

Reads up to numBytes bytes from handle, beginning at the byte offset supplied as the decimal string offset.

This form is intended for environments without native 64-bit integer support. The offset is ignored when the file was opened with textMode.

Returns TRUE for success, FALSE for failure.

top
ReadFileBytes64sAsync Deprecated (1)
HCkTask CkSFtp_ReadFileBytes64sAsync(HCkSFtp cHandle, const char *handle, const char *offset, int numBytes);

Creates an asynchronous task to call the ReadFileBytes64s method with the arguments provided.

Returns NULL on failure

top
WriteFileBytes Deprecated
BOOL CkSFtp_WriteFileBytes(HCkSFtp cHandle, const char *handle, HCkByteData byteData);

Appends the exact bytes in byteData to the remote file identified by handle. The handle must have been returned by OpenFile.

Returns TRUE for success, FALSE for failure.

top
WriteFileBytesAsync Deprecated (1)
HCkTask CkSFtp_WriteFileBytesAsync(HCkSFtp cHandle, const char *handle, HCkByteData byteData);

Creates an asynchronous task to call the WriteFileBytes method with the arguments provided.

Returns NULL on failure

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

Writes the exact bytes in data to handle at the 32-bit byte offset from the beginning of the remote file.

Returns TRUE for success, FALSE for failure.

top
WriteFileBytes32Async Deprecated (1)
HCkTask CkSFtp_WriteFileBytes32Async(HCkSFtp cHandle, const char *handle, int offset, HCkByteData data);

Creates an asynchronous task to call the WriteFileBytes32 method with the arguments provided.

Returns NULL on failure

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

Writes the exact bytes in data to handle at the 64-bit byte offset64 from the beginning of the remote file.

Returns TRUE for success, FALSE for failure.

top
WriteFileBytes64Async Deprecated (1)
HCkTask CkSFtp_WriteFileBytes64Async(HCkSFtp cHandle, const char *handle, __int64 offset64, HCkByteData data);

Creates an asynchronous task to call the WriteFileBytes64 method with the arguments provided.

Returns NULL on failure

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

Writes the exact bytes in data to handle at the byte offset supplied as the decimal string offset64.

Returns TRUE for success, FALSE for failure.

top
WriteFileBytes64sAsync Deprecated (1)
HCkTask CkSFtp_WriteFileBytes64sAsync(HCkSFtp cHandle, const char *handle, const char *offset64, HCkByteData data);

Creates an asynchronous task to call the WriteFileBytes64s method with the arguments provided.

Returns NULL on failure

top