Re: [AD] Clarifying and revising filesystem API

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


On 2009-04-17, Elias Pschernig <elias.pschernig@xxxxxxxxxx> wrote:
> Peter Wang wrote:
> > 
> > Let me propose again a URI-like scheme, and strip the API down to
> > stream operations only.
> > 
> > 
> > ## API: al_register_stream_handler
> > 
> >     bool al_register_stream_handler(const char *scheme,
> > 	ALLEGRO_FILE_VTABLE *vtable);
> > 
> > Register a handler for a particular scheme.  The scheme must be a
> > non-empty string, not containing any colon characters, e.g. "file".
> > vtable is a pointer to a table of function pointers.  The functions will
> > be used to operate on the streams which were opened with the particular
> > scheme.
> > 
> > By default, the scheme "file" is registered and is handled using the C
> > library stdio functions.
> 
> Could we have a function to set a per-thread default handler? The use cases I 
> can think of would make things a lot simpler with that as I don't have to mess 
> with prepending schemes to copies of my filename strings all the time. Something 
> like:
> 
> al_set_default_stream_handler(ALLEGRO_FILE_VTABLE *vtable);
> 
> Passing NULL would reset to the builtin one.

I'm not particularly opposed to it, but I don't think prepending is that
hard, using al_ustr_newf() for example.  What cases are you thinking of?

> > ## Writing to a memory block
> > 
> >     /* You need to generate a unique token somehow.
> >      * The addon could help you, or you could follow a convention
> >      * like Java package names.
> >      */
> >     const char *token = "mem:b3457c95-db59-480d-91d0-9d0f61a6e7d1";
> > 
> 
> I find this really confusing... when doing it like this, what is the remaining 
> advantage of using this over the _entry version?

You wouldn't need two versions of every function, the string version and the
_entry version.


Elsewhere:
> My vote also goes for directory operations. It's very common in games (e.g. list 
> all files in the savegames folder).

Ok.  How about we keep directory operations but in a distinct part of the
API?  It wouldn't use ALLEGRO_FILEs and you couldn't hook the functions, so
they would only work with the local disk.  Then the questions about the
current directory would have obvious answers.

Peter





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