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<Count;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.