[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sftp_read receives EOF on second call for a 24kb file


On Wednesday 23 October 2013 09:45:00 Kevin Lambert wrote:
> I just modified my code as such:
> 
> 
> 
>     size_t count = 0;
> 
>     size_t totalLength = 0;
> 
>   char buffer[1024];
> 
>   size_t length = sizeof(buffer);
> 
> 
> 
>     count = sftp_read(file, buffer, length);
> 
> 
> 
>     while ( count > 0 ) {
> 
> 
> 
>       if ( destFile.is_open() ) {
> 
>         destFile.write(buffer, length);
> 
>       }
> 
> 
> 
>       totalLength += count;
> 
> 
> 
>       sftp_seek(file, totalLength);
> 
>       count = sftp_read(file, buffer, length);
> 
>     }

Your loop has several bugs. I've showed you earlier how to use the API and how 
the loop should look like. If you ignore it, it isn't our fault.

I've written a test for master and backported it to 0.5. In all versions 
sftp_read() is working correctly, if correctly used.

http://git.libssh.org/projects/libssh.git/commit/?h=v0-5&id=87549f7bb6a570481f377e628001a04175f7d3a5


	-- andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx


References:
RE: sftp_read receives EOF on second call for a 24kb file"Kevin Lambert" <klambert@xxxxxxxxx>
Re: sftp_read receives EOF on second call for a 24kb fileDarren <d.tomlin@xxxxxxxxxxxx>
RE: sftp_read receives EOF on second call for a 24kb file"Kevin Lambert" <klambert@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org