You need to do this call:
LIBSSH2_SFTP_ATTRIBUTES fileinfo;
LIBSSH2_SESSION *session;
........
session = libssh2_session_init();
sftp_session = libssh2_sftp_init(session);
status= status=libssh2_sftp_stat(sftp_session,"/tmp/myfile",&fileinfo);
If status=0 then "/tmp/myfile" exists.
________________________________
From: libssh2-devel-bounces_at_cool.haxx.se
[mailto:libssh2-devel-bounces_at_cool.haxx.se] On Behalf Of royconejo
Sent: Friday, 24 July 2009 1:15 PM
To: libssh2-devel_at_cool.haxx.se
Subject: libssh2_sftp_open() error values
Hello,
How could I know if a given file exists over SFTP? requesting directory
contents in not a good choice (I suppose) because there'll be hundreds
of files and retrieving and searching in that list will be way slower
than just trying to open the file, as one could do in the local
filesystem (for example with fopen, open, etc)
well, libssh2_sftp_open() returns NULL whenever it fails, but how could
I discern if it was because of the ?
Shoud I always expect an errno to be set, even when there was no
connection error? perhaps ERROR_NONE since there was no real error apart
from the file not being there?
And shoud I expect any reliable behaviour when my local or remote
machine lost connection? perhaps LIBSSH2_ERROR_SOCKET_SEND when I unplug
my local machine or LIBSSH2_ERROR_SOCKET_TIMEOUT when the remote host
fails?
(Perhaps I'm a little confused and things are not that easy =p)
Thanks in advance =)!
***************************************************************
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily the views of the Department of Lands. This email message has been swept by MIMEsweeper for the presence of computer viruses.
***************************************************************
Please consider the environment before printing this email.
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2009-07-24