Subject: Re: Error reporting of libssh2_sftp_xxxx functions.

Re: Error reporting of libssh2_sftp_xxxx functions.

From: Daniel Stenberg <>
Date: Mon, 23 Mar 2009 19:55:40 +0100 (CET)

On Mon, 23 Mar 2009, Jean-Louis CHARTON wrote:

> My problem is that if I try to create a directory thanks to
> libssh2_sftp_mkdir(), and if the directory already exists on the remote SSH
> server, libssh2_sftp_mkdir() fails; which is what I'm expecting so far; BUT
> the error returned by libssh2_sftp_last_error() is either 4 (i.e.
> LIBSSH2_FX_FAILURE) if the SSH server is an openssh running on a Linux box
> or 5 (i.e. LIBSSH2_FX_BAD_MESSAGE) if the server is a freeSSHD server
> running on a Windows 2003 server box. In both cases, the error code returned
> by libssh2_session_last_error() is -31 (i.e. LIBSSH2_ERROR_SFTP_PROTOCOL).

libssh2_sftp_last_error() simply returns that error the server responded with.
libssh2 is "only" talking SFTP protocol version 3 which might be a reason or
perhaps the servers just don't give a more detailed answer...

> I was expecting a more accurate error code like
> LIBSSH2_FX_FILE_ALREADY_EXISTS or something like that instead.

There is no such code available! See

Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial.
libssh2-devel mailing list
Received on 2009-03-23