Re: [AD] implementing seek

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, Apr 8, 2010 at 4:24 AM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
>> It does not work with sequential files, but it could if a memory
>> buffer were implemented upon detecting (if possible) that random
>> access was not allowed.
>
> Or add it as a flag in the third parameter.
>
I'm thinking about implementing:

ALLEGRO_FILE_SLICE_EXPAND

As already described and implemented.

ALLEGRO_FILE_SLICE_BUFFER

Reads the entire 'size' bytes into memory for random access. Then the
parent is never touched again. So the effect is the parent is always
left untouched and open after 'size' bytes.

Thus it is safe to use the parent and the slice simultaneously. If you
want to write the slice back to the parent, you would need to do that
explicitly before closing the slice.

(Alternatively, data could be read from the parent as needed, but then
you wouldn't be able to use the two simultaneously. I haven't
completely thought this through yet.)

This would turn a forward-only sequential stream (e.g., a network)
into something suitable for an image loader or saver.

This could essentially be a convenience layer over something like memfile.

ALLEGRO_FILE_SLICE_READONLY

All calls to fwrite on the slice would fail. This is mostly useful for
turning a BUFFER slice into a read-only stream. Not compatible with
EXPAND.

--
Matthew Leverton




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/