From 61fda23340f2a068a63194753f55d276752a8316 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 29 Sep 2008 14:11:29 +0000 Subject: [PATCH] - Based on bug #1815692, we introduce libssh2_sftp_seek2() that allows seeking beyond the 2GB margin even on 32bit machines. --- NEWS | 3 +++ docs/libssh2_sftp_seek.3 | 7 ++++++- include/libssh2_sftp.h | 5 +++-- src/sftp.c | 13 ++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 9be751d9..ac247ab1 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ Version 0.19 ( ) ------------------------------- +- Based on bug #1815692, we introduce libssh2_sftp_seek2() that allows seeking + beyond the 2GB margin even on 32bit machines. + - Based on a patch in bug #1878059 by Steven Ayre libssh2 now parses >2GB file sizes when downloading SCP files. diff --git a/docs/libssh2_sftp_seek.3 b/docs/libssh2_sftp_seek.3 index 62eaeb9e..6614881a 100644 --- a/docs/libssh2_sftp_seek.3 +++ b/docs/libssh2_sftp_seek.3 @@ -1,4 +1,4 @@ -.\" $Id: libssh2_sftp_seek.3,v 1.1 2007/06/14 16:08:43 jehousley Exp $ +.\" $Id: libssh2_sftp_seek.3,v 1.2 2008/09/29 14:11:30 bagder Exp $ .\" .TH libssh2_sftp_seek 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual" .SH NAME @@ -10,6 +10,9 @@ libssh2_sftp_seek - set the read/write position indicator within a file void libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle, size_t offset); +void +libssh2_sftp_seek2(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset); + .SH DESCRIPTION \fIhandle\fP - SFTP File Handle as returned by .BR libssh2_sftp_open(3) @@ -22,5 +25,7 @@ file access appear more POSIX like. No packets are exchanged with the server during a seek operation. The localized file pointer is simply used as a convenience offset during read/write operations. +Note that the \fBlibssh2_sftp_seek2(3)\fP function was added in 0.19 to make it +possible to seek in large files even on 32bit systems. .SH SEE ALSO .BR libssh2_sftp_open(3) diff --git a/include/libssh2_sftp.h b/include/libssh2_sftp.h index 596eb0bc..0ad5c13f 100644 --- a/include/libssh2_sftp.h +++ b/include/libssh2_sftp.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2007, Sara Golemon +/* Copyright (c) 2004-2008, Sara Golemon * All rights reserved. * * Redistribution and use in source and binary forms, @@ -206,7 +206,8 @@ LIBSSH2_API int libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle); #define libssh2_sftp_closedir(handle) libssh2_sftp_close_handle(handle) LIBSSH2_API void libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle, size_t offset); -#define libssh2_sftp_rewind(handle) libssh2_sftp_seek((handle), 0) +LIBSSH2_API void libssh2_sftp_seek2(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset); +#define libssh2_sftp_rewind(handle) libssh2_sftp_seek2((handle), 0) LIBSSH2_API size_t libssh2_sftp_tell(LIBSSH2_SFTP_HANDLE *handle); diff --git a/src/sftp.c b/src/sftp.c index baf0c4bb..e797a9d6 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2007, Sara Golemon +/* Copyright (c) 2004-2008, Sara Golemon * All rights reserved. * * Redistribution and use in source and binary forms, @@ -1528,6 +1528,17 @@ libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE * handle, size_t offset) /* }}} */ +/* {{{ libssh2_sftp_seek2 + * Set the read/write pointer to an arbitrary position within the file + */ +LIBSSH2_API void +libssh2_sftp_seek2(LIBSSH2_SFTP_HANDLE * handle, libssh2_uint64_t offset) +{ + handle->u.file.offset = offset; +} + +/* }}} */ + /* {{{ libssh2_sftp_tell * Return the current read/write pointer's offset */