GNOME Bugzilla – Bug 724357
Convert all occurrences of "stat()" to GFileInfo in browser.c
Last modified: 2014-02-14 14:53:20 UTC
browser.c currently uses stat () from stdio at many occurrences. All usage of stat must be replaced by better GFileInfo from GIO.
Created attachment 269116 [details] [review] This patch will change occurrences of stat from stdio to GFileInfo from GIO
Review of attachment 269116 [details] [review]: Looks good overall, just some style comments. ::: src/browser.c @@ +2742,3 @@ + G_FILE_QUERY_INFO_NONE, NULL, + NULL); + if (!fileinfo) You should leave a blank line before the if(). @@ +2745,2 @@ { g_free(npath); Unrelated to your patch, but as npath is freed in both the error and non-error case, you should move the free to after the GFile has been created, since it is no longer needed at that point. @@ +2755,3 @@ { + g_object_unref (fileinfo); + g_object_unref (file); You can unref the GFile immediately after creating the GFileInfo, which saves doing it here and then again below. @@ +2979,3 @@ } + if (fileinfo) + g_object_unref (fileinfo); I think that it is better to move the unref up to after where you call g_file_query_info(). Then you can do something like: if (fileinfo) { if (g_file_info_get_type() == foo) { stuff; } g_object_unref (fileinfo); }
Created attachment 269125 [details] [review] Converted all occurrences of stat of stdio to GFileInfo of GIO. Did all the changes from above post.
Comment on attachment 269125 [details] [review] Converted all occurrences of stat of stdio to GFileInfo of GIO. Thanks. I pushed a slightly-modified version to master as 4381597a181c96b8786857825eb8f9b05bb48e50.