1libssh2_sftp_fstat_ex(3)        libssh2 manual        libssh2_sftp_fstat_ex(3)
2
3
4

NAME

6       libssh2_sftp_fstat_ex - get or set attributes on an SFTP file handle
7

SYNOPSIS

9       #include <libssh2.h>
10       #include <libssh2_sftp.h>
11
12       int
13       libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *handle,
14                             LIBSSH2_SFTP_ATTRIBUTES *attrs, int setstat)
15
16       #define libbssh2_sftp_fstat(handle, attrs) \
17           libssh2_sftp_fstat_ex((handle), (attrs), 0)
18       #define libssh2_sftp_fsetstat(handle, attrs) \
19           libssh2_sftp_fstat_ex((handle), (attrs), 1)
20

DESCRIPTION

22       handle - SFTP File Handle as returned by libssh2_sftp_open_ex(3)
23
24       attrs  -  Pointer  to  an LIBSSH2_SFTP_ATTRIBUTES structure to set file
25       metadata from or into depending on the value of setstat.
26
27       setstat - When non-zero, the file's metadata will be updated  with  the
28       data  found  in attrs according to the values of attrs->flags and other
29       relevant member attributes.
30
31       Get or Set statbuf type data for a given LIBSSH2_SFTP_HANDLE instance.
32

DATA TYPES

34       LIBSSH2_SFTP_ATTRIBUTES is a typedefed struct that is defined as below
35
36       struct _LIBSSH2_SFTP_ATTRIBUTES {
37
38           /* If flags & ATTR_* bit is set, then the value in this
39            * struct will be meaningful Otherwise it should be ignored
40            */
41           unsigned long flags;
42
43           /* size of file, in bytes */
44           libssh2_uint64_t filesize;
45
46           /* numerical representation of the user and group owner of
47            * the file
48            */
49           unsigned long uid, gid;
50
51           /* bitmask of permissions */
52           unsigned long permissions;
53
54           /* access time and modified time of file */
55           unsigned long atime, mtime;
56       };
57
58       You will find a full set of defines and macros to  identify  flags  and
59       permissions  on  the  libssh2_sftp.h  header file, but some of the most
60       common ones are:
61
62       To check for specific user permissions, the set of defines are  in  the
63       pattern  LIBSSH2_SFTP_S_I<action><who>  where <action> is R, W or X for
64       read, write and excutable and <who> is USR, GRP and OTH for user, group
65       and  other.  So,  you  check for a user readable file, use the bit LIB‐
66       SSH2_SFTP_S_IRUSR while you want to see if it is executable for  other,
67       you use LIBSSH2_SFTP_S_IXOTH and so on.
68
69       To  check for specific file types, you would previously (before libssh2
70       1.2.5) use the standard posix S_IS***() macros, but since 1.2.5 libssh2
71       offers its own set of macros for this functionality:
72
73       LIBSSH2_SFTP_S_ISLNK
74              Test for a symbolic link
75
76       LIBSSH2_SFTP_S_ISREG
77              Test for a regular file
78
79       LIBSSH2_SFTP_S_ISDIR
80              Test for a directory
81
82       LIBSSH2_SFTP_S_ISCHR
83              Test for a character special file
84
85       LIBSSH2_SFTP_S_ISBLK
86              Test for a block special file
87
88       LIBSSH2_SFTP_S_ISFIFO
89              Test for a pipe or FIFO special file
90
91       LIBSSH2_SFTP_S_ISSOCK
92              Test for a socket
93

RETURN VALUE

95       Return   0  on  success  or  negative  on  failure.   It  returns  LIB‐
96       SSH2_ERROR_EAGAIN  when  it   would   otherwise   block.   While   LIB‐
97       SSH2_ERROR_EAGAIN  is  a negative number, it isn't really a failure per
98       se.
99

ERRORS

101       LIBSSH2_ERROR_ALLOC -  An internal memory allocation call failed.
102
103       LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket.
104
105       LIBSSH2_ERROR_SOCKET_TIMEOUT -
106
107       LIBSSH2_ERROR_SFTP_PROTOCOL - An invalid  SFTP  protocol  response  was
108       received  on the socket, or an SFTP operation caused an errorcode to be
109       returned by the server.
110

AVAILABILITY

112       This function has been around since  forever,  but  most  of  the  LIB‐
113       SSH2_SFTP_S_*  defines  were  introduced  in  libssh2 0.14 and the LIB‐
114       SSH2_SFTP_S_IS***() macros were introduced in libssh2 1.2.5.
115

SEE ALSO

117       libssh2_sftp_open_ex(3)
118
119
120
121libssh2 0.15                      1 Jun 2007          libssh2_sftp_fstat_ex(3)
Impressum