1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-08-08 19:02:07 +03:00

add libssh2_scp_recv2 to support large (> 2GB) files on windows

This commit is contained in:
David Byron
2015-06-29 17:16:43 -07:00
committed by Alexander Lamaison
parent 4961014033
commit 6c84a426be
14 changed files with 167 additions and 18 deletions

View File

@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
const char *username="username";
const char *password="password";
const char *scppath="/tmp/TEST";
struct stat fileinfo;
libssh2_struct_stat fileinfo;
int rc;
off_t got=0;
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
}
/* Request a file via SCP */
channel = libssh2_scp_recv(session, scppath, &fileinfo);
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
if (!channel) {
fprintf(stderr, "Unable to open a session: %d\n",
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
int amount=sizeof(mem);
if((fileinfo.st_size -got) < amount) {
amount = fileinfo.st_size -got;
amount = (int)(fileinfo.st_size -got);
}
rc = libssh2_channel_read(channel, mem, amount);

View File

@@ -88,16 +88,16 @@ int main(int argc, char *argv[])
const char *username="username";
const char *password="password";
const char *scppath="/tmp/TEST";
struct stat fileinfo;
libssh2_struct_stat fileinfo;
#ifdef HAVE_GETTIMEOFDAY
struct timeval start;
struct timeval end;
long time_ms;
#endif
int rc;
int total = 0;
int spin = 0;
off_t got=0;
libssh2_struct_stat_size got = 0;
libssh2_struct_stat_size total = 0;
#ifdef WIN32
WSADATA wsadata;
@@ -207,9 +207,9 @@ int main(int argc, char *argv[])
#endif
/* Request a file via SCP */
fprintf(stderr, "libssh2_scp_recv()!\n");
fprintf(stderr, "libssh2_scp_recv2()!\n");
do {
channel = libssh2_scp_recv(session, scppath, &fileinfo);
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
if (!channel) {
if(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
@@ -235,7 +235,7 @@ int main(int argc, char *argv[])
int amount=sizeof(mem);
if ((fileinfo.st_size -got) < amount) {
amount = fileinfo.st_size - got;
amount = (int)(fileinfo.st_size - got);
}
/* loop until we block */
@@ -262,10 +262,10 @@ int main(int argc, char *argv[])
gettimeofday(&end, NULL);
time_ms = tvdiff(end, start);
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
time_ms, total/(time_ms/1000.0), spin );
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
time_ms, total/(time_ms/1000.0), spin);
#else
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes spin: %d\n", total, spin);
#endif
libssh2_channel_free(channel);

View File

@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
/* Other channel types are supported via:
* libssh2_scp_send()
* libssh2_scp_recv()
* libssh2_scp_recv2()
* libssh2_channel_direct_tcpip()
*/

View File

@@ -217,7 +217,7 @@ int main(int argc, char *argv[])
/* Other channel types are supported via:
* libssh2_scp_send()
* libssh2_scp_recv()
* libssh2_scp_recv2()
* libssh2_channel_direct_tcpip()
*/