[wx-dev] [wxFTP] how to get size of buffer?
Chris Elliott
biol75 at york.ac.uk
Sun Apr 20 08:00:52 PDT 2008
I would suggest reading a big file like this in several small chunks,
eg 1024 bytes at a time, as then you can show and update a progress
dialog, allowing the user to exit gracefully if the network link fails.
chris
On 19 Apr 2008, at 00:35, Christian Buhtz wrote:
> I used the sample-code from
> <http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin_wxftp.html>
> to download a file.
>
> The buffer-size there is allocated with this:
> [code]
> wxInputStream *in = ftp.GetInputStream("wxWidgets-4.2.0.tar.gz");
> // ..
> size_t size = in->GetSize();
> char *data = new char[size];
> [/code]
>
> But GetSize() returns 0 (of course!) because it is a socket-stream.
> Please see the docs about wxStreamBase::GetSize() for more detailes.
>
> Ok, I understand this.
> Now I tried wxFTP::GetFileSize() for this.
> But it returns always -1. But wxFTP::FileExists() always returns true.
>
> How can I handle this? How do I know the size of the buffer to
> allocate?
>
> For more detailes please see
> <http://wxforum.shadonet.com/viewtopic.php?t=19033>
>
> btw: Where can I find the tex-file about wxFTP in the SVN? Maybe I
> write
> a patch for the wxFTP-sample code in the doc.
>
> _______________________________________________
> wx-dev mailing list
> wx-dev at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-dev
More information about the wx-dev
mailing list