[Libssh] sftp - determining directory item types
Aris Adamantiadis
aris at 0xbadc0de.be
Thu May 15 15:49:58 CEST 2008
Mike Taylor a écrit :
> Seems like I can probably use the first character of the long name to
> determine the type of the entry. How safe is that?
>
> /\/\ike
>
> On 15-May-08, at 7:43 AM, Mike Taylor wrote:
>
>> Hello all,
>>
>> I've recently picked up libssh and everything is going very well.
>>
>> I did hit a problem however. I'm reading the elements of a
>> directory via sftp and I noticed that the "type" field is not set in
>> the SFTP_ATTRIBUTES structure. That means I cannot tell which
>> directory entries are files and which are directories. Knowing that
>> is pretty fundamental to what I'm doing.
>>
>> Any suggestions would be greatly appreciated! I'm willing to help
>> out and submit a patch if need be.
>>
>> /\/\ike
>>
>
Hello,
I wouldn't trust the first character. The SFTP_ATTRIBUTE structure is
badly designed because the sftp draft completely changed it at every
version. So, to answer correctly your question i'd need the version of
the sftp protocol your server is speaking. (I think there is a libssh
function to tell that).
Regards,
Aris
More information about the Libssh
mailing list