libssh2_sftp_fstat_ex.3 (3553B)
1.TH libssh2_sftp_fstat_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2" 2.SH NAME 3libssh2_sftp_fstat_ex - get or set attributes on an SFTP file handle 4.SH SYNOPSIS 5.nf 6#include <libssh2.h> 7#include <libssh2_sftp.h> 8 9int 10libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *handle, 11 LIBSSH2_SFTP_ATTRIBUTES *attrs, int setstat) 12 13#define libssh2_sftp_fstat(handle, attrs) \\ 14 libssh2_sftp_fstat_ex((handle), (attrs), 0) 15#define libssh2_sftp_fsetstat(handle, attrs) \\ 16 libssh2_sftp_fstat_ex((handle), (attrs), 1) 17.fi 18.SH DESCRIPTION 19\fIhandle\fP - SFTP File Handle as returned by 20.BR libssh2_sftp_open_ex(3) 21 22\fIattrs\fP - Pointer to an LIBSSH2_SFTP_ATTRIBUTES structure to set file 23metadata from or into depending on the value of setstat. 24 25\fIsetstat\fP - When non-zero, the file's metadata will be updated 26with the data found in attrs according to the values of attrs->flags 27and other relevant member attributes. 28 29Get or Set statbuf type data for a given LIBSSH2_SFTP_HANDLE instance. 30.SH DATA TYPES 31LIBSSH2_SFTP_ATTRIBUTES is a typedefed struct that is defined as below 32 33.nf 34struct _LIBSSH2_SFTP_ATTRIBUTES { 35 36 /* If flags & ATTR_* bit is set, then the value in this 37 * struct will be meaningful Otherwise it should be ignored 38 */ 39 unsigned long flags; 40 41 /* size of file, in bytes */ 42 libssh2_uint64_t filesize; 43 44 /* numerical representation of the user and group owner of 45 * the file 46 */ 47 unsigned long uid, gid; 48 49 /* bitmask of permissions */ 50 unsigned long permissions; 51 52 /* access time and modified time of file */ 53 unsigned long atime, mtime; 54}; 55.fi 56 57You will find a full set of defines and macros to identify flags and 58permissions on the \fBlibssh2_sftp.h\fP header file, but some of the 59most common ones are: 60 61To check for specific user permissions, the set of defines are in the 62pattern LIBSSH2_SFTP_S_I<action><who> where <action> is R, W or X for 63read, write and executable and <who> is USR, GRP and OTH for user, 64group and other. So, you check for a user readable file, use the bit 65\fILIBSSH2_SFTP_S_IRUSR\fP while you want to see if it is executable 66for other, you use \fILIBSSH2_SFTP_S_IXOTH\fP and so on. 67 68To check for specific file types, you would previously (before libssh2 691.2.5) use the standard posix S_IS***() macros, but since 1.2.5 70libssh2 offers its own set of macros for this functionality: 71.IP LIBSSH2_SFTP_S_ISLNK 72Test for a symbolic link 73.IP LIBSSH2_SFTP_S_ISREG 74Test for a regular file 75.IP LIBSSH2_SFTP_S_ISDIR 76Test for a directory 77.IP LIBSSH2_SFTP_S_ISCHR 78Test for a character special file 79.IP LIBSSH2_SFTP_S_ISBLK 80Test for a block special file 81.IP LIBSSH2_SFTP_S_ISFIFO 82Test for a pipe or FIFO special file 83.IP LIBSSH2_SFTP_S_ISSOCK 84Test for a socket 85.SH RETURN VALUE 86Return 0 on success or negative on failure. It returns 87LIBSSH2_ERROR_EAGAIN when it would otherwise block. While 88LIBSSH2_ERROR_EAGAIN is a negative number, it is not really a failure per se. 89.SH ERRORS 90\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed. 91 92\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket. 93 94\fILIBSSH2_ERROR_SOCKET_TIMEOUT\fP - 95 96\fILIBSSH2_ERROR_SFTP_PROTOCOL\fP - An invalid SFTP protocol response was 97received on the socket, or an SFTP operation caused an errorcode to 98be returned by the server. 99.SH AVAILABILITY 100This function has been around since forever, but most of the 101LIBSSH2_SFTP_S_* defines were introduced in libssh2 0.14 and the 102LIBSSH2_SFTP_S_IS***() macros were introduced in libssh2 1.2.5. 103.SH SEE ALSO 104.BR libssh2_sftp_open_ex(3)