GNOME Bugzilla – Bug 700359
Use GFile instead of stdio in et_core.c in EasyTAG
Last modified: 2013-05-18 13:57:27 UTC
EasyTAG currently uses fopen, fclose in et_core.c. Instead of this use GIO from GFile. This will simplify file handling, name of file handling encoding, could also help in making Asynchronous I/O and with this EasyTAG could be used over NFS and CIFS/Samba shares.
Created attachment 244271 [details] [review] Use GIO instead of stdio in et_core.c
Review of attachment 244271 [details] [review]: ::: src/et_core.c @@ +2764,2 @@ /* Show/hide 'AccessStatusIcon' */ + if (g_file_query_exists (file, NULL)) You need to additionally check if the file is readable by the current user, as in the switch statement in the else branch. As the g_file_query_exists() documentation mentions nothing of setting errno, you cannot assume that it does. @@ +4586,2 @@ { gchar *filename_utf8 = filename_to_display(filename); As you have the GFileInfo, you should get the display name using g_file_info_get_display_name(). However, in this case querying the file for information has already failed. It would be best to change this function (ET_Read_File_Info) to take a GError argument and to set the error if an error occurs, so that the calling function can display a log message as necessary. @@ +4598,3 @@ ETFileInfo->samplerate = 0; ETFileInfo->mode = 0; + ETFileInfo->size = g_file_info_get_size (info); g_file_info_get_size() returns a goffset, so you should change the size field of ET_File_Info to also be a goffset.
Created attachment 244277 [details] [review] Did all the changes In ET_Display_File_Data_To_UI, compiler gives warning about message and emblem_icon. But all the cases has been covered as you can see so that message and emblem_icon could be initialized. Also, in that case the code written could have been better to read if I would have used GFileInputStream to open the file (in this case too checking for write and execute permissions would not be possible) and check for errors. But I don't think it would be much efficient as compared to using GFileInfo. Also, the code has been changed according to the switch case statement. I mean the way switch case statement would behave, similarly this will.
Review of attachment 244277 [details] [review]: ::: src/et_core.c @@ +2781,3 @@ + attributes = g_strjoin (",", G_FILE_ATTRIBUTE_ACCESS_CAN_READ, + G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, + G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE, NULL); You do not need to join the strings together dynamically. Simply concatenate the defines together like: G_FILE_ATTRIBUTE_ACCESS_CAN_READ "," G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE "," G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE @@ +2835,3 @@ + gtk_entry_set_icon_from_gicon (GTK_ENTRY (FileEntry), + GTK_ENTRY_ICON_SECONDARY, + emblem_icon); You set the icon twice here in the all-permissions case. Additionally, you use emblem_icon, which has not been initialized in the all-permissions case. I guess that this is the compiler warning that you mentioned. @@ +2837,3 @@ + emblem_icon); + gtk_entry_set_icon_tooltip_text (GTK_ENTRY (FileEntry), + GTK_ENTRY_ICON_SECONDARY, message); The same comment applies here for message as it does for emblem_icon.
Created attachment 244287 [details] [review] Done!! oh!! yeah I realized it for all permissions case. Apology to gcc :P.
Created attachment 244289 [details] [review] There was whitespaces error in previous patch I didn't know why, but git apply --check doesn't check for whitespaces :o. I applied the patch then got whitespace error.
Review of attachment 244289 [details] [review]: ::: src/et_core.c @@ +573,3 @@ + if (!ET_Read_File_Info (filename, ETFileInfo, &error)) + { + gchar *filename_utf8 = filename_to_display(filename); Missing a space before the opening parenthesis. @@ +577,3 @@ + filename_utf8, error->message); + g_error_free (error); + g_free(filename_utf8); Missing a space before the opening parenthesis. @@ +2777,3 @@ + file = g_file_new_for_path (cur_filename); + attributes = G_FILE_ATTRIBUTE_ACCESS_CAN_READ "," G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE "," G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE; There is no need to have a separate variable for this. @@ +2861,3 @@ gtk_label_set_text(GTK_LABEL(FileIndex),text); + g_object_unref (file); + g_free (attributes); You should not free something that has not been dynamically allocated.
Created attachment 244295 [details] [review] Corrected one now!!
Created attachment 244296 [details] [review] Ignore previous one please!!
Review of attachment 244296 [details] [review]: I pushed a modified version of this patch to master as commit b37e622a8358864b9f2e0317ad014d709a5d6af1, and improved it a bit with commit ace584e56ab3de44a5548d920f01985cf6e36307.
Bug is being reopened, as there is an error message. GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed while renaming the file(s)
Created attachment 244613 [details] [review] This patch will fix the above bug
Comment on attachment 244613 [details] [review] This patch will fix the above bug Thanks. I pushed a modified patch to master as commit 8f26298550ad88b62bbf7d19d986d9baf291fcc5.