Re: [AD] Clarifying and revising filesystem API

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


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.


## 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?

--
Elias Pschernig <elias@xxxxxxxxxx>




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