The AttributesData callback will be called as a result of
ListAttributes
methods. It's purpose is to provide information about
directory structure in a way that is easy for your application to parse. Instead of using ListDir, which returns
line-by-line directory contents that depend on the server,
you can use the ListAttributes method to retrieve a collection of
objects - each of them containing one directory item.
For example, you can easily get information about specific
item, like this:
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;
}
This event can fire more than once when a directory
contains many items. When the complete directory listing is
finished, the Done event will
fire.
WIN32_FIND_DATA structure contains dwFileAttributes member
which holds item type. It will be set to 0 if remote file is a
regular file. When remote item is a directory, it will be set to
FILE_ATTRIBUTE_DIRECTORY. If remote item is a symbolic link, it
will be set to FILE_ATTRIBUTE_SYMLINK (defined in SftpDLL.h
header file, has same value as unused
FILE_ATTRIBUTE_REPARSE_POINT).
NOTE: this callback is called only if
you have created an instance of the SftpEventsStruct structure, and set its AttributesData member to the
function implementing it.