Re: [AD] file slices

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


On 2011-07-18, Matthew Leverton <meffer@xxxxxxxxxx> wrote:
> This has been brought up a couple of times... same general concept
> here: allow a user to open up a subset of an already opened file. Its
> main use cases are:
> 
> * loading a resource from within a custom data file of a known size
> 
> * converting a sequential access file into a random access file
> 
> It's not much different from the core memfile function, but it does
> let you work with a subset of a file without having to create a memory
> buffer (first use case), and in some cases, it feels more natural than
> manually creating a memfile.
> 
> I've implemented the following as a file interface:
> 
> ALLEGRO_FILE *al_fslice(ALLEGRO_FILE *fp, size_t initial_size, const
> char *mode);
> size_t al_get_fslice_size(ALLEGRO_FILE *fp);
> uint8_t *al_get_fslice_buffer(ALLEGRO_FILE *fp);

al_fslice needs a verb, of course.

Is al_get_fslice_size different from al_fsize?

> Or another option could be: 1) remove the buffered option from file
> slices and make it a core function and 2) add expandable memfiles into
> the memfile addon.

This seems like a good idea, for keeping the code simpler (although, if
you have written the code already..).  Does this mean if you want to
layer a random access file on top of a sequential file, you will need to
manually read from the sequential file and copy the bytes into a
memfile?  Or we could add a memfile function that does that.
Either way, I don't consider it a big deal.

Peter




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