mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-07 08:02:56 +03:00
sftp: add open functions with custom attribute support
Before this patch, libssh2 sent hardcoded `LIBSSH2_SFTP_ATTRIBUTES` struct on handle open. This can be problematic on some special OS, where the file size should be known on new file creation. I added two new functions to resolve this issue. Patch-by: @vajdaakos on github via #506 Changes compared to #506: - drop attr size fixup in favour of #946. - move `memcpy()` under the state where we need it. - bump filename length type to `size_t`. - fix filenames in documentation and other nits. Closes #506 Closes #947
This commit is contained in:
@@ -238,6 +238,17 @@ libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp,
|
||||
libssh2_sftp_open_ex((sftp), \
|
||||
(path), (unsigned int)strlen(path), \
|
||||
0, 0, LIBSSH2_SFTP_OPENDIR)
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *
|
||||
libssh2_sftp_open_ex_r(LIBSSH2_SFTP *sftp,
|
||||
const char *filename,
|
||||
size_t filename_len,
|
||||
unsigned long flags,
|
||||
long mode, int open_type,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
#define libssh2_sftp_open_r(sftp, filename, flags, mode, attrs) \
|
||||
libssh2_sftp_open_ex_r((sftp), (filename), strlen(filename), \
|
||||
(flags), (mode), LIBSSH2_SFTP_OPENFILE, \
|
||||
(attrs))
|
||||
|
||||
LIBSSH2_API ssize_t libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle,
|
||||
char *buffer, size_t buffer_maxlen);
|
||||
|
Reference in New Issue
Block a user