david wrote:
> My proposal to correct this in Linux is as follows, it adds the overhead
> of a second call to g_file_test but retains the return code structure
>    if (g_file_test(filename, G_FILE_TEST_IS_REGULAR) && !g_file_test
>       (filename, G_FILE_TEST_IS_SYMLINK) )
>       retcode = FILE_TYPE_FILE;/* regular but not symlink*/
>   else if (g_file_test(filename, G_FILE_TEST_IS_DIR) && !g_file_test
>           (filename, G_FILE_TEST_IS_SYMLINK) )
>            retcode = FILE_TYPE_DIR;/* dir but not symlink*/
>   else if (g_file_test(filename, G_FILE_TEST_IS_SYMLINK))
>            retcode =  FILE_TYPE_LINK;/*regular or directory symlink
> (does not exist in windows)*/
>   else
>     retcode = FILE_TYPE_UNKNOWN;

The cleaner solution to the above is to test for a symlink first and then do 
the other tests (as shown below). Thanks for spotting this.

   if (g_file_test(filename, G_FILE_TEST_IS_SYMLINK))
     retcode =  FILE_TYPE_LINK;
   else if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
     retcode = FILE_TYPE_FILE;
   else if (g_file_test(filename, G_FILE_TEST_IS_DIR))
     retcode = FILE_TYPE_DIR;
     retcode = FILE_TYPE_UNKNOWN;



http://www.ve3syb.ca/           |"What are we going to do today, Borg?"
Owner of Elecraft K2 #2172      |"Same thing we always do, Pinkutus:
                                 |  Try to assimilate the world!"
#include <disclaimer/favourite> |              -Pinkutus & the Borg
Gimp-developer mailing list

Reply via email to