Re: Utility functions from gnome-libs



On 3 Jul 2000, Owen Taylor wrote:
>>> enum {
>>> G_FILE_TEST_ISFILE=1<<0,
>>> G_FILE_TEST_ISLINK=1<<1,
>>> G_FILE_TEST_ISDIR=1<<2,
>>> G_FILE_TEST_EXISTS=(1<<0)|(1<<1)|(1<<2) /*any type of file*/
>>> };
>>> 
>>> gboolean g_file_test   (const char *filename, int test);
>>> gboolean g_file_exists (const char *filename);
>>> 
>>> (These might alternatively be called g_file_race() ;-), but
>>> they are useful for a lot of things, and a note in the
>>> docs about security implications should be OK.)

Tim Janik <timj@gtk.org> writes:
>> no, that's not a good idea. instead, it'll probably not hurt to
>> simply implement g_file_test() in terms of:
>> 
>> typedef enum
>> {
>> G_FILE_IS_FILE    = 1 << 0,
>> G_FILE_IS_LINK    = 1 << 1,
>> G_FILE_IS_DIR        = 1 << 2,
>> G_FILE_EXISTS        = G_FILE_IS_FILE | G_FILE_IS_LINK | G_FILE_IS_DIR
>> } GFileType;
>>
>> GFileType g_file_test (const char *filename);

on 7/5/00 11:27 AM, Owen Taylor at otaylor@redhat.com wrote:
> Yes, the enumeration should be named, not anonymous. Was there
> another objection or was that all?

I believe Tim's point was that all the tests are done atomically instead of
passing in the test you want to do, and this would somehow minimize the race
conditions.

    -- Darin





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