Re: Proposal to modify ftx.c to correct foreign_filetype function's use of g_file_test on *ux machines

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

 



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;
   else
     retcode = FILE_TYPE_UNKNOWN;

-- 
Cheers!

Kevin.

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
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux