TrustCore SDK NanoSSH API reference  version 7.0
SFTP Client Directory Listing Functions

Functions

MOC_EXTERN sbyte4 SSHC_closeDirectory (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr)
 Close a directory on an SFTP server. More...
 
MOC_EXTERN sbyte4 SSHC_openDirectory (sbyte4 connectionInstance, ubyte *pPath, ubyte4 pathLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
 
MOC_EXTERN sbyte4 SSHC_readDirectory (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte **ppRetFilename, ubyte4 *pRetFilenameLen)
 Get a directory's list of files (using a read directory request). More...
 
MOC_EXTERN void SSHC_sftpGetDirEntryFilePermission (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFilePermission, intBoolean *pRetIsPresent)
 Determine whether a directory's file permission flag is set. More...
 
MOC_EXTERN void SSHC_sftpGetDirEntryFileSize (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileSize, intBoolean *pRetIsPresent)
 Get a directory's size (number of bytes). More...
 
MOC_EXTERN void SSHC_sftpGetDirEntryFileType (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileType, intBoolean *pRetIsPresent)
 Get a directory's type. More...
 

Detailed Description

Function Documentation

◆ SSHC_closeDirectory()

MOC_EXTERN sbyte4 SSHC_closeDirectory ( sbyte4  connectionInstance,
sftpcFileHandleDescr p_sftpFileHandleDescr 
)

This function sends a close directory request to the connected SSH/SFTP server to close an open directory, disabling it from further access.

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().
p_sftpFileHandleDescrFile handle returned from SSHC_openDirectory().
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_openDirectory()

MOC_EXTERN sbyte4 SSHC_openDirectory ( sbyte4  connectionInstance,
ubyte *  pPath,
ubyte4  pathLen,
sftpcFileHandleDescr **  pp_sftpFileHandleDescr 
)

Open a directory. This function sends an open directory 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().
pPathPointer to buffer containing directory name.
pathLenNumber of bytes (characters) in the directory name (pPath).
pp_sftpFileHandleDescrPointer to address of handle descriptor structure, which on return contains the opened directory's information.
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.
Note
A directory must be open before it can be read.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h

◆ SSHC_readDirectory()

MOC_EXTERN sbyte4 SSHC_readDirectory ( sbyte4  connectionInstance,
sftpcFileHandleDescr p_sftpFileHandleDescr,
ubyte **  ppRetFilename,
ubyte4 *  pRetFilenameLen 
)

This function sends a read directory request to the connected SSH/SFTP server to return the specified directory's list of files (through the ppRetFilename parameter).

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().
p_sftpFileHandleDescrPointer to handle descriptor structure containing the desired directory's information.
ppRetFilenamePointer to address of ubyte buffer, which on return contains the directory's filenames as strings.
pRetFilenameLenPointer to ubyte4, which on return contains the number of bytes in the ppRetFilename buffer.
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_sftpGetDirEntryFilePermission()

MOC_EXTERN void SSHC_sftpGetDirEntryFilePermission ( sbyte4  connectionInstance,
sftpcFileHandleDescr p_sftpFileHandleDescr,
ubyte4 *  pRetFilePermission,
intBoolean *  pRetIsPresent 
)

This function determines the specified directory's attributes are set. If so, TRUE is returned through the pRetIsPresent parameter, and the pRetFilePermission parameter value is set to TRUE or FALSE to indicate whether the SSH_FILEXFER_ATTR_PERMISSIONS bit flag is set or clear in the directory attribute's bitmask. If the attributes are not set, FALSE is returned trough the pRetFilePermission parameter.

For a list of handle descriptor attribute flags, see sshc_hnd_desc_flags.

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().
p_sftpFileHandleDescrPointer to file handle descriptor.
pRetFilePermission(Valid only if pRetIsPresent value is TRUE) On return, pointer to TRUE (if the attribute's SSH_FILEXFER_ATTR_PERMISSIONS bit flag is set) or FALSE.
pRetIsPresentOn return, pointer to TRUE (if the handle descriptor's directory attributes are set) or FALSE.
Returns
None.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h

◆ SSHC_sftpGetDirEntryFileSize()

MOC_EXTERN void SSHC_sftpGetDirEntryFileSize ( sbyte4  connectionInstance,
sftpcFileHandleDescr p_sftpFileHandleDescr,
ubyte4 *  pRetFileSize,
intBoolean *  pRetIsPresent 
)

This function determines whether the specified directory's attributes are set. If so, TRUE is returned through the pRetIsPresent parameter, and the directory attribute's SSH_FILEXFER_ATTR_SIZE bit flag is checked. If the bit flag is set, the RetFileSize parameter value is set to the number of bytes used by the directory; otherwise the RetFileSize value is set to 0.

For a list of handle descriptor attribute flags, see sshc_hnd_desc_flags.

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().
p_sftpFileHandleDescrPointer to file handle descriptor.
pRetFileSize(Valid only if pRetIsPresent value is TRUE) On return, pointer to number of bytes used by the directory (if the attribute's SSH_FILEXFER_ATTR_SIZE bit flag is set) or 0.
pRetIsPresentOn return, pointer to TRUE (if the handle descriptor's directory attributes are set) or FALSE.
Returns
None.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h

◆ SSHC_sftpGetDirEntryFileType()

MOC_EXTERN void SSHC_sftpGetDirEntryFileType ( sbyte4  connectionInstance,
sftpcFileHandleDescr p_sftpFileHandleDescr,
ubyte4 *  pRetFileType,
intBoolean *  pRetIsPresent 
)

This function determines whether the specified directory's attributes are set. If so, TRUE is returned through the pRetIsPresent parameter, and the directory attribute's type is returned through the pRetFileType parameter.

Note
The directory type is available only for SFTP version 4 and later. If this function is called for SFTP versions 3 and earlier, FALSE is returned through the pRetIsPresent parameter.
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().
p_sftpFileHandleDescrPointer to file handle descriptor.
pRetFileType(Valid only if pRetIsPresent value is TRUE) On return, pointer to value indicating directory type (definitions in ssh_defs.h):
  • SSH_FILEXFER_TYPE_REGULAR
  • SSH_FILEXFER_TYPE_DIRECTORY
  • SSH_FILEXFER_TYPE_SYMLINK
  • SSH_FILEXFER_TYPE_SPECIAL
  • SSH_FILEXFER_TYPE_UNKNOWN
pRetIsPresentOn return, pointer to TRUE (if the handle descriptor's directory attributes are set) or FALSE.
Returns
None.
Remarks
This function is applicable to synchronous SFTP clients.

sshc.h