Re: gdk-pixbuf: *no* save xpm patch



At 10:33 01.11.00 -0500, Havoc Pennington wrote:
>
>Hans Breuer <hans breuer org> writes: 
>> What about g_get_tmp_filename("gdkpixbuf-xpm-tmp") to get the best of both
>> worlds?
>> 
>
>If you have get_tmp_filename() there's a race condition before you
>open the file, right?
>
Actually with the Win32 specific implementation there won't be one,
because GetTempFileName already creates the file and also makes the
tempfilename unique during one session. (It is simple with short up-times ...)

>The idea of passing in an identifying part of the name is a good one
>though. How about:
>
>  gint g_file_open_tmp (const gchar *identifier,
>                        GError     **error);
>
My suggestions was about "who is owning" the temp filename.
At the moment the caller needs to free the name, which may not be as near 
in the sources, as it is in gdk-pixbuf's usage.

As a result the required modifications would be less straightforward.

>So usage is e.g.:
>
>int fd = g_file_open_tmp ("gdk-pixbuf-io-xpm", &error);
>
>and the error can be set to the usual GFileError stuff.
>
>Only problem I see is that there's no way to get the filename, so
>maybe the filename should be returned as an optional out param?
>
int g_file_open_tmp (const char* template,
                     char** name_selected, /* NULL if not needed */
                     GError** error);      /* NULL if not needed */

could do the trick, althoug IHMO it appears to be a little bit bloated ...

Additional there would be te usual problem with different allocators:

char* s = new char[256];
...
/* the function may be called with an application generated
 * filename, too.
 */
fd = g_mkstemp(s);
...
delete [] s;

would simply work, but with g_file_open_tmp it would require to read the
reference documentation.

	Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]