TrustCore SDK NanoSSH API reference  version 7.0
SFTP Client File and Directory Management Functions

Functions

MOC_EXTERN sbyte4 SSHC_getFileStat (sbyte4 connectionInstance, ubyte *pGetStatFile, ubyte4 getStatFileLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
 Get a file's statistics from an SFTP server. More...
 
MOC_EXTERN sbyte4 SSHC_mkdir (sbyte4 connectionInstance, ubyte *pNewDirName, ubyte4 newDirNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr, void *pFuture)
 Create a directory on an SFTP server. More...
 
MOC_EXTERN sbyte4 SSHC_realpath (sbyte4 connectionInstance, ubyte *pRealpath, ubyte4 realpathLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr, ubyte **ppRetRealpath, ubyte4 *pRetRealpathLen)
 Get the fully-qualified directory path of an an SSH Client's virtual directory. More...
 
MOC_EXTERN sbyte4 SSHC_removeFile (sbyte4 connectionInstance, ubyte *pRemoveFileName, ubyte4 removeFileNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
 Delete a file from an SFTP server. More...
 
MOC_EXTERN sbyte4 SSHC_rmdir (sbyte4 connectionInstance, ubyte *pRemoveDirName, ubyte4 removeDirNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
 Delete a directory from an SFTP server. More...
 

Detailed Description

Function Documentation

◆ SSHC_getFileStat()

MOC_EXTERN sbyte4 SSHC_getFileStat ( sbyte4  connectionInstance,
ubyte *  pGetStatFile,
ubyte4  getStatFileLen,
sftpcFileHandleDescr **  pp_sftpFileHandleDescr 
)

This function sends a request to the connected SSH/SFTP server to return the specified file's statistics, such as file size and type.

Since
1.41
Version
1.41 and later

To enable this function, the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_CLIENT__
  • __ENABLE_MOCANA_SSH_FTP_CLIENT__

sshc.h

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
pGetStatFilePointer to buffer containing name of file to evaluate.
getStatFileLenNumber of bytes (characters) in the filename (getStatFileLen).
pp_sftpFileHandleDescrPointer to address of handle descriptor structure, which on return contains file's statistics.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h

◆ SSHC_mkdir()

MOC_EXTERN sbyte4 SSHC_mkdir ( sbyte4  connectionInstance,
ubyte *  pNewDirName,
ubyte4  newDirNameLen,
sftpcFileHandleDescr **  pp_sftpFileHandleDescr,
void *  pFuture 
)

This function sends create directory request to the connected SSH/SFTP server to create a directory as specified by the function parameter values.

Since
1.41
Version
1.41 and later

To enable this function, the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_CLIENT__
  • __ENABLE_MOCANA_SSH_FTP_CLIENT__

sshc.h

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
pNewDirNamePointer to buffer containing desired directory name.
newDirNameLenNumber of bytes (characters) in the desired directory name (pNewDirName).
pp_sftpFileHandleDescrPointer to address of handle descriptor structure, which on return contains the created directory's information.
pFuture(Reserved for future use.)
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h

◆ SSHC_realpath()

MOC_EXTERN sbyte4 SSHC_realpath ( sbyte4  connectionInstance,
ubyte *  pRealpath,
ubyte4  realpathLen,
sftpcFileHandleDescr **  pp_sftpFileHandleDescr,
ubyte **  ppRetRealpath,
ubyte4 *  pRetRealpathLen 
)

This function retrieves (from the connected SSH/SFTP server) the fully-qualified directory path corresponding to the specified SSH Client's virtual directory. This is useful for converting path names containing ".." components, or relative pathnames without a leading slash, into absolute paths.

Since
1.41
Version
1.41 and later

To enable this function, the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_CLIENT__
  • __ENABLE_MOCANA_SSH_FTP_CLIENT__

sshc.h

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
pRealpathPointer to buffer containing SSH Client's virtual directory name.
realpathLenNumber of bytes (characters) in the virtual directory name (pRealpath).
pp_sftpFileHandleDescrPointer to address of handle descriptor structure, which on return contains real directory's information.
ppRetRealpathPointer to address of ubyte buffer, which on return contains the real directory's name as a string.
pRetRealpathLenPointer to ubyte4, which on return contains the number of bytes in the real directory's name (ppRetRealpath).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h

◆ SSHC_removeFile()

MOC_EXTERN sbyte4 SSHC_removeFile ( sbyte4  connectionInstance,
ubyte *  pRemoveFileName,
ubyte4  removeFileNameLen,
sftpcFileHandleDescr **  pp_sftpFileHandleDescr 
)

This function sends a delete file request to the connected SSH/SFTP server.

Since
1.41
Version
1.41 and later

To enable this function, the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_CLIENT__
  • __ENABLE_MOCANA_SSH_FTP_CLIENT__

sshc.h

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
pRemoveFileNamePointer to buffer containing name of file to delete.
removeFileNameLenNumber of bytes (characters) in the filename (pRemoveFileName).
pp_sftpFileHandleDescrPointer to address of file's handle descriptor structure; on return it will be NULL.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h

◆ SSHC_rmdir()

MOC_EXTERN sbyte4 SSHC_rmdir ( sbyte4  connectionInstance,
ubyte *  pRemoveDirName,
ubyte4  removeDirNameLen,
sftpcFileHandleDescr **  pp_sftpFileHandleDescr 
)

This function sends a delete direcotyr request to the connected SSH/SFTP server.

Since
1.41
Version
1.41 and later

To enable this function, the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_CLIENT__
  • __ENABLE_MOCANA_SSH_FTP_CLIENT__

sshc.h

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
pRemoveDirNamePointer to buffer containing name of directory to delete.
removeDirNameLenNumber of bytes (characters) in the directory name (pRemoveDirName).
pp_sftpFileHandleDescrPointer to address of directory's handle descriptor structure; on return it will be NULL.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h