[tracker] tracker-extract, gif: Don't use a FILE* when we don't have to



commit b41bb1787539c30cf6e45411ef60ced5a3a724b4
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Sep 22 17:11:34 2011 +0200

    tracker-extract, gif: Don't use a FILE* when we don't have to

 src/tracker-extract/tracker-extract-gif.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index 982dc74..35ddcfb 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -24,6 +24,13 @@
 #define _GNU_SOURCE
 #endif
 
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
 #include <gif_lib.h>
 
 #include <libtracker-common/tracker-common.h>
@@ -584,7 +591,6 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
 	const gchar *graph;
 	gchar *filename, *uri;
 	GFile *file;
-	FILE *f;
 	int fd;
 
 	preupdate = tracker_extract_info_get_preupdate_builder (info);
@@ -600,12 +606,15 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
 		return FALSE;
 	}
 
-	f = tracker_file_open (filename);
-	if (!f) {
-		return FALSE;
-	}
+	fd = g_open (filename, O_RDONLY | O_NOATIME, 0);
 
-	fd = fileno (f);
+	if (fd == -1) {
+		g_warning ("Could not open gif file '%s': %s\n",
+		           filename,
+		           g_strerror (errno));
+		g_free (filename);
+		return FALSE;
+	}	
 
 	if ((gifFile = DGifOpenFileHandle (fd)) == NULL) {
 		PrintGifError ();
@@ -631,7 +640,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
 		PrintGifError ();
 	}
 
-	tracker_file_close (f, FALSE);
+	close (fd);
 
 	return TRUE;
 }



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