gthumb r2468 - in trunk: . libgthumb src



Author: mjc
Date: Wed Dec 24 01:36:25 2008
New Revision: 2468
URL: http://svn.gnome.org/viewvc/gthumb?rev=2468&view=rev

Log:
2008-12-23  Michael J. Chudobiak  <mjc svn gnome org>

        * libgthumb/file-data.c: (load_info):
        Turn off verbose error reports.

        * libgthumb/file-utils.c: (can_read_write_execute):
        * libgthumb/file-utils.h:
        * src/dlg-file-utils.c: (dlg_check_folder):
        * src/dlg-photo-importer.c: (ok_clicked_cb):
        Convert gnomevfs-based check_permissions to gfile-based
        can_read_write_execute.



Modified:
   trunk/ChangeLog
   trunk/libgthumb/file-data.c
   trunk/libgthumb/file-utils.c
   trunk/libgthumb/file-utils.h
   trunk/src/dlg-file-utils.c
   trunk/src/dlg-photo-importer.c

Modified: trunk/libgthumb/file-data.c
==============================================================================
--- trunk/libgthumb/file-data.c	(original)
+++ trunk/libgthumb/file-data.c	Wed Dec 24 01:36:25 2008
@@ -87,8 +87,9 @@
 		fd->display_name = g_strdup (g_file_info_get_display_name (info));
 		fd->can_read = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
 		fd->mime_type = get_static_string (g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE));
+		g_object_unref (info);
         } else {
-                gfile_warning ("Failed to get file information", gfile, error);
+                // gfile_warning ("Failed to get file information", gfile, error);
                 g_error_free (error);
 
 		fd->size = (goffset) 0;
@@ -98,7 +99,6 @@
 		fd->can_read = TRUE;
 	}
 
-	g_object_unref (info);
 	g_object_unref (gfile);
 }
 

Modified: trunk/libgthumb/file-utils.c
==============================================================================
--- trunk/libgthumb/file-utils.c	(original)
+++ trunk/libgthumb/file-utils.c	Wed Dec 24 01:36:25 2008
@@ -2544,35 +2544,36 @@
 
 
 gboolean
-check_permissions (const char *path,
-		   int         mode)
+can_read_write_execute (const char *path)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    vfs_result;
-	gboolean	  everything_OK = TRUE;
-
-	info = gnome_vfs_file_info_new ();
-	vfs_result = gnome_vfs_get_file_info (path,
-					      info,
-					      (GNOME_VFS_FILE_INFO_DEFAULT
-					       | GNOME_VFS_FILE_INFO_FOLLOW_LINKS
-					       | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS));
-
-	if (vfs_result != GNOME_VFS_OK)
-		everything_OK = FALSE;
-
-	if ((mode & R_OK) && ! (info->permissions & GNOME_VFS_PERM_ACCESS_READABLE))
-		everything_OK = FALSE;
-
-	if ((mode & W_OK) && ! (info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE))
-		everything_OK = FALSE;
-
-	if ((mode & X_OK) && ! (info->permissions & GNOME_VFS_PERM_ACCESS_EXECUTABLE))
-		everything_OK = FALSE;
+	GFileInfo *info;
+	GFile     *gfile;
+	GError    *error = NULL;
+	gboolean   result, a, b, c;
+
+	gfile = gfile_new (path);
+        info = g_file_query_info (gfile,
+				  G_FILE_ATTRIBUTE_ACCESS_CAN_READ ","
+				  G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE ","
+                                  G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE,
+				  G_FILE_QUERY_INFO_NONE,
+				  NULL,
+				  &error);
+
+	if (error != NULL) {
+		gfile_warning ("Failed to get directory permission information", gfile, error);
+		g_error_free (error);
+		result = FALSE;
+	} else {
+		result = ((a=g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) &&
+			  (b=g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) &&
+			  (c=g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)));
+	}
 
-	gnome_vfs_file_info_unref (info);
+	g_object_unref (info);
+	g_object_unref (gfile);
 
-	return everything_OK;
+	return result;
 }
 
 

Modified: trunk/libgthumb/file-utils.h
==============================================================================
--- trunk/libgthumb/file-utils.h	(original)
+++ trunk/libgthumb/file-utils.h	Wed Dec 24 01:36:25 2008
@@ -255,8 +255,7 @@
 						   gboolean          fast_file_type);
 const char *        get_mime_type_from_ext        (const char       *ext);
 gboolean            is_mime_type_writable         (const char       *mime_type);
-gboolean            check_permissions             (const char       *path,
-						   int               mode);
+gboolean            can_read_write_execute        (const char       *path);
 gboolean	    is_local_file                 (const char       *filename);
 char *              get_cache_filename_from_uri   (const char       *uri);
 char *              get_cache_uri_from_uri        (const char       *uri);

Modified: trunk/src/dlg-file-utils.c
==============================================================================
--- trunk/src/dlg-file-utils.c	(original)
+++ trunk/src/dlg-file-utils.c	Wed Dec 24 01:36:25 2008
@@ -114,7 +114,7 @@
 
 	/* check permissions */
 
-	if (! check_permissions (dir, R_OK | W_OK | X_OK)) {
+	if (! can_read_write_execute (dir)) {
 		char *utf8_path;
 		utf8_path = get_utf8_display_name_from_uri (dir);
 		_gtk_error_dialog_run (GTK_WINDOW (window),

Modified: trunk/src/dlg-photo-importer.c
==============================================================================
--- trunk/src/dlg-photo-importer.c	(original)
+++ trunk/src/dlg-photo-importer.c	Wed Dec 24 01:36:25 2008
@@ -1761,7 +1761,7 @@
 		return;
 	}
 
-	if (! check_permissions (data->local_folder, R_OK | W_OK | X_OK)) {
+	if (! can_read_write_execute (data->local_folder)) {
 		char *utf8_path;
 		char *msg;
 		utf8_path = get_utf8_display_name_from_uri (data->local_folder);



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