[AD] al_make_temp

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


I'm wondering how useful the flags on al_make_temp() actually will be.
The flags are:
    ALLEGRO_MAKE_TEMP_REMOVE_ON_OPEN,
    ALLEGRO_MAKE_TEMP_REMOVE_ON_CLOSE

* ALLEGRO_MAKE_TEMP_REMOVE_ON_OPEN

This creates an anonymous temporary file, which will only work on some
platforms.  The file is anonymous so you can't write stuff to the file
then pass its file name to another process.  Nor can you do anything
with the underlying file descriptor, as we haven't provided a function
to get it.  All you can do is read/write to it using the same
ALLEGRO_FILE handle, within the same process.  That might be
occasionally useful, but it's also not cross-platform.
We have a function to delete files anyway so this flag only actually
saves one line of code.

* ALLEGRO_MAKE_TEMP_REMOVE_ON_CLOSE

Deleting the file on al_fclose() is probably too soon.  One of the main
reasons to create a temporary file is to pass it off to another process.
If you use this flag you would need to call the other process *without*
closing the file first, which is unusual.  I believe on Windows it also
wouldn't work as a process can't open a file for reading while another
has it open for closing.

It seems like if you use this flag, you have to accept only
reading/writing to a file within the same process using the one
ALLEGRO_FILE handle.  Same as before, but more portable.

A minor problem is that the user probably intends for the temporary file
to always be cleaned up, but it won't happen if the program crashes.  I
think handling that in Allegro would be too messy, so the user would
need to do it himself with a signal handler.  But then, if the user does
all that, the flag feels a little bit useless.


Comments?

Peter





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