Back to product page
- Introduction
- Overview
- License agreement
- Classes
- Enumerations
- wodSFTPdll
- Create function
- Destroy function
- Methods
- Abort
- About
- AppendData
- AppendDataLen
- AppendFile
- Connect
- DeleteFile
- DeleteFiles
- Disconnect
- ExtendedCmd
- GetAttributes
- GetData
- GetDataAt
- GetDataToBuffer
- GetDataToBufferAt
- GetFile
- GetFileAt
- GetFiles
- ListAttributes
- ListDir
- ListNames
- LoadPrivateKey
- LoopFiles
- MakeDir
- PutData
- PutDataAt
- PutDataLen
- PutDataLenAt
- PutFile
- PutFileAt
- PutFiles
- RealPath
- RemoteClose
- RemoteOpen
- RemoteRead
- RemoteWrite
- RemoveDir
- Rename
- SetAttributes
- Properties
- Authentication
- Blocking
- BufferSize
- ClientName
- Compression
- Encryption
- EncryptionList
- ErrorText
- Extensions
- FIPS
- HMacList
- Hostname
- KeyExchangeList
- KeySignatureList
- LastError
- ListItem
- LocalPath
- Login
- MaxTransferRate
- MyHostname
- MyIP
- Password
- Port
- PrivateKey
- ProxyHostname
- ProxyLogin
- ProxyPassword
- ProxyPort
- ProxyType
- RemoteIdentification
- RemotePath
- Resume
- ServerErrorCode
- ServerErrorText
- State
- StateText
- Timeout
- Timezone
- TransferMode
- TransferRate
- TransferTime
- UseIPv6
- Version
- Callbacks
- How to get support
- Using callbacks
- Technical information
- Error list
ListAttributes function
Lists the contents of a directory as a structure.
Type
A Long value. If successful, 0 is returned, otherwise error as specified hereSyntax
- C
long Sftp_ListAttributes(void *Sftp, char *RemotePath);
The ListAttributes(void *Sftp,char *RemotePath) syntax has these parts:
The ListAttributes(void *Sftp,char *RemotePath) syntax has these parts:
void *Sftp | Handle of the created Sftp instance. |
char *RemotePath | Full path to directory on the server. |
Remarks
The ListAttributes function will send a request to the server to retrieve a complete directory structure in an array of WIN32_FIND_DATA structures, rather than a line-by-line listing that needs to be parsed. As a result of this method call, the AttributesData callback will be invoked (possibly more than once if there are many files in the directory). Once completed, the Done callback will be called. If no error occurs, the ErrorCode argument in the Done callback will be set to 0 (zero). If an error occurrs, ErrorCode will hold the number of the error and ErrorText will contain a description of the error. No wildcards can be used with the RemotePath argument. The RFC protocol specification for SFTP does not allow them. The code in this example will loop through all received items:void SftpAttributesData(void *Sftp, int Count, WIN32_FIND_DATA **Items)
{
char *it = (char *)Items;
for (int i=0;i
WIN32_FIND_DATA *dt = (WIN32_FIND_DATA *)it;
SYSTEMTIME st;
FileTimeToSystemTime(&dt->ftLastWriteTime, &st);
........
........
it += sizeof(WIN32_FIND_DATA);
}
return;
}
To retrieve a full listing of files/directories on a given path (including size, permissions, dates...) you should use the ListDir function. To get names only, you can use ListNames.