wxInputStream and SeekI function

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
rem
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sun Apr 24, 2005 5:02 pm

wxInputStream and SeekI function

Post by rem » Sun Apr 24, 2005 5:19 pm

I need in my application to change the stream position in the wxInputStream object and I used the SeekI() function and it does not work at all. I read in the documentation that the seek functions doesn't work on all streams. Do you have any ideas how to solve this problem. Thanks.

User avatar
Ryan Norton
Moderator
Moderator
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Re: wxInputStream and SeekI function

Post by Ryan Norton » Sun Apr 24, 2005 6:13 pm

rem wrote:I need in my application to change the stream position in the wxInputStream object and I used the SeekI() function and it does not work at all. I read in the documentation that the seek functions doesn't work on all streams. Do you have any ideas how to solve this problem. Thanks.
What kind of stream? Could you post some code?

Anyway, if the stream really doesn't support seek, just read data into a temporary buffer until you get to the position you desire.
[Mostly retired moderator, still check in to clean up some stuff]

rem
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sun Apr 24, 2005 5:02 pm

Post by rem » Sun Apr 24, 2005 6:35 pm

The piece of code looks like this

wxURL url("http://a.host/a.dir/a.file");

wxInputStream* i_stream = url.GetInputStream();

i_stream->SeekI(newposition, wxFromStart);

Anyway, if the stream really doesn't support seek, just read data into a temporary buffer until you get to the position you desire.

I could do that but what if the file has 10MB?
I had to wait for 5 minutes to read the data i'm interested in.

mjs
Experienced Solver
Experienced Solver
Posts: 93
Joined: Wed Feb 09, 2005 3:53 am
Contact:

Post by mjs » Tue May 03, 2005 10:30 pm

AFAIK seeking and querying the input stream size aren't supported for i-net streams (http and ftp).

I think the problem with seeking is that it works in a different way. When using SeekI, the file has to be open already. But when you query data using http or ftp, you have to specify the read position together with your read request (or before when using ftp).

Regards,
Mark

rem
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sun Apr 24, 2005 5:02 pm

Post by rem » Thu May 05, 2005 11:51 am

Yes, that's it. Range : "bytes=10-20" for example. Thanks Mark.

Post Reply