gthumb r2471 - in trunk: . libgthumb



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

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

        * libgthumb/file-data.c: (load_info):
        Removed obsolete comment.

        * libgthumb/file-utils.c: (get_file_mtime), (get_file_ctime),
        (set_file_mtime):
        Migrated these functions to gfile.



Modified:
   trunk/ChangeLog
   trunk/libgthumb/file-data.c
   trunk/libgthumb/file-utils.c

Modified: trunk/libgthumb/file-data.c
==============================================================================
--- trunk/libgthumb/file-data.c	(original)
+++ trunk/libgthumb/file-data.c	Wed Dec 24 02:29:01 2008
@@ -67,7 +67,6 @@
 		g_free (fd->display_name);
 
 	gfile = gfile_new (fd->path);
-	/* FIXME: do we want to read the mime type here? */
 	info = g_file_query_info (gfile, 
 				  G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
 				  G_FILE_ATTRIBUTE_STANDARD_SIZE ","

Modified: trunk/libgthumb/file-utils.c
==============================================================================
--- trunk/libgthumb/file-utils.c	(original)
+++ trunk/libgthumb/file-utils.c	Wed Dec 24 02:29:01 2008
@@ -745,6 +745,7 @@
 	return xfer_file (from, to, TRUE);
 }
 
+
 gboolean
 file_rename (const char *from,
 	     const char *to)
@@ -912,6 +913,7 @@
 	return result;
 }
 
+
 gboolean
 path_is_dir (const char *path)
 {
@@ -953,24 +955,30 @@
 time_t
 get_file_mtime (const char *path)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	time_t            mtime;
+        GFileInfo *info;
+        GFile     *gfile;
+        GError    *error = NULL;
+        GTimeVal   tv;
+	time_t     mtime;
 
-	if (! path || ! *path) return 0;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (path,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	mtime = 0;
-	if ((result == GNOME_VFS_OK)
-	    && (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MTIME))
-		mtime = info->mtime;
-
-	gnome_vfs_file_info_unref (info);
+        gfile = gfile_new (path);
+        info = g_file_query_info (gfile,
+                                  G_FILE_ATTRIBUTE_TIME_MODIFIED,
+                                  G_FILE_QUERY_INFO_NONE,
+                                  NULL,
+                                  &error);
+
+        if (error == NULL) {
+                g_file_info_get_modification_time (info, &tv);
+                mtime = tv.tv_sec;
+		g_object_unref (info);
+        } else {
+                // gfile_warning ("Failed to get file information", gfile, error);
+                g_error_free (error);
+                mtime = (time_t) 0;
+        }
 
+        g_object_unref (gfile);
 	return mtime;
 }
 
@@ -978,24 +986,28 @@
 time_t
 get_file_ctime (const gchar *path)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult result;
-	time_t ctime;
+        GFileInfo *info;
+        GFile     *gfile;
+        GError    *error = NULL;
+        time_t     ctime;
 
-	if (! path || ! *path) return 0;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (path,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	ctime = 0;
-	if ((result == GNOME_VFS_OK)
-	    && (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_CTIME))
-		ctime = info->ctime;
-
-	gnome_vfs_file_info_unref (info);
+        gfile = gfile_new (path);
+        info = g_file_query_info (gfile,
+                                  G_FILE_ATTRIBUTE_TIME_CHANGED,
+                                  G_FILE_QUERY_INFO_NONE,
+                                  NULL,
+                                  &error);
+
+        if (error == NULL) {
+                ctime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CHANGED);
+                g_object_unref (info);
+        } else {
+                // gfile_warning ("Failed to get file information", gfile, error);
+                g_error_free (error);
+                ctime = (time_t) 0;
+        }
 
+        g_object_unref (gfile);
 	return ctime;
 }
 
@@ -1004,15 +1016,26 @@
 set_file_mtime (const gchar *path,
 		time_t       mtime)
 {
-	GnomeVFSFileInfo *file_info;
+        GFileInfo *info;
+        GFile     *gfile;
+        GError    *error = NULL;
+        GTimeVal   tv;
+
+	tv.tv_sec = mtime;
+ 	tv.tv_usec = 0;
+
+        gfile = gfile_new (path);
+        info = g_file_info_new ();
+	g_file_info_set_modification_time (info, &tv);
+	g_file_set_attributes_from_info (gfile, info, G_FILE_QUERY_INFO_NONE, NULL, &error);
+	g_object_unref (info);
+
+        if (error != NULL) {
+                gfile_warning ("Failed to set file mtime", gfile, error);
+                g_error_free (error);
+        }
 
-	file_info = gnome_vfs_file_info_new ();
-	file_info->mtime = mtime;
-	file_info->atime = mtime;
-	gnome_vfs_set_file_info (path,
-				 file_info,
-				 GNOME_VFS_SET_FILE_INFO_TIME);
-	gnome_vfs_file_info_unref (file_info);
+        g_object_unref (gfile);
 }
 
 



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