[gthumb] Use gfile_set_mtime instead of set_file_mtime



commit 6f21235e19c55d8aea9c77c37ca980d95d9201f9
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Sun Jun 7 16:17:23 2009 -0400

    Use gfile_set_mtime instead of set_file_mtime
---
 libgthumb/file-utils.c  |   17 +----------------
 libgthumb/gfile-utils.c |   23 +++++++++++++++++++++++
 libgthumb/gfile-utils.h |    2 ++
 src/dlg-change-date.c   |    3 ++-
 4 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 81b6258..705e345 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -926,25 +926,10 @@ void
 set_file_mtime (const gchar *path,
 		time_t       mtime)
 {
-        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);
-        }
-
+	gfile_set_mtime (gfile, mtime);
         g_object_unref (gfile);
 }
 
diff --git a/libgthumb/gfile-utils.c b/libgthumb/gfile-utils.c
index 2e625fd..99af0ab 100644
--- a/libgthumb/gfile-utils.c
+++ b/libgthumb/gfile-utils.c
@@ -871,3 +871,26 @@ gfile_list_free (GList *list)
         g_list_free (list);
 }
 
+
+void
+gfile_set_mtime (GFile  *gfile,
+                 time_t  mtime)
+{
+        GFileInfo *info;
+        GError    *error = NULL;
+        GTimeVal   tv;
+
+        tv.tv_sec = mtime;
+        tv.tv_usec = 0;
+
+        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);
+        }
+}
+
diff --git a/libgthumb/gfile-utils.h b/libgthumb/gfile-utils.h
index ea9634e..65f8429 100644
--- a/libgthumb/gfile-utils.h
+++ b/libgthumb/gfile-utils.h
@@ -74,6 +74,8 @@ gboolean      gfile_is_file                    (GFile      *file);
 gboolean      gfile_is_dir                     (GFile      *file);
 goffset       gfile_get_file_size              (GFile      *file);
 char *        gfile_get_display_name           (GFile      *file);
+void          gfile_set_mtime                  (GFile      *gfile,
+                                                time_t      mtime);
 
 /* Directory utils */
 
diff --git a/src/dlg-change-date.c b/src/dlg-change-date.c
index 81a9ce6..237959c 100644
--- a/src/dlg-change-date.c
+++ b/src/dlg-change-date.c
@@ -33,6 +33,7 @@
 #include "file-data.h"
 #include "gth-exif-utils.h"
 #include "file-utils.h"
+#include "gfile-utils.h"
 #include "gth-utils.h"
 #include "gth-window.h"
 #include "main.h"
@@ -146,7 +147,7 @@ ok_clicked (GtkWidget  *button,
 			continue;
 
 		if (is_active (data->cd_last_modified_checkbutton))
-			set_file_mtime (fdata->utf8_path, mtime);
+			gfile_set_mtime (fdata->gfile, mtime);
 
 		if (is_active (data->cd_comment_checkbutton)) {
 			CommentData *cdata;



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