[tracker/tracker-0.10-no-atime: 13/23] tracker-extract, tiff: Don't use a FILE* when we don't have to



commit 3083ffab8617238d97a0e01bd6a9980e11a19e50
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Sep 22 17:10:20 2011 +0200

    tracker-extract, tiff: Don't use a FILE* when we don't have to
    
    Conflicts:
    
    	src/tracker-extract/tracker-extract-tiff.c

 src/tracker-extract/tracker-extract-tiff.c |   33 +++++++++++++++++----------
 1 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 7e2d44a..ae248ab 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -20,6 +20,17 @@
 
 #include "config.h"
 
+#ifndef _GNU_SOURCE
+#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 <glib/gstdio.h>
 
 #include <tiffio.h>
@@ -269,7 +280,6 @@ extract_tiff (const gchar          *uri,
 	GPtrArray *keywords;
 	guint i;
 	GString *where = NULL;
-	FILE *mfile = NULL;
 	int fd;
 
 #ifdef HAVE_LIBIPTCDATA
@@ -284,18 +294,20 @@ extract_tiff (const gchar          *uri,
 
 	filename = g_filename_from_uri (uri, NULL, NULL);
 
-	mfile = tracker_file_open (filename);
-	
-	if (!mfile) {
-		return;
-	}
+	fd = g_open (filename, O_RDONLY | O_NOATIME, 0);
 
-	fd = fileno (mfile);
+	if (fd == -1) {
+		g_warning ("Could not open tiff file '%s': %s\n",
+		           filename,
+		           g_strerror (errno));
+		g_free (filename);
+		return;
+	}	
 
 	if ((image = TIFFFdOpen (fd, filename, "r")) == NULL){
 		g_warning ("Could not open image:'%s'\n", filename);
 		g_free (filename);
-		tracker_file_close (mfile, FALSE);
+		close (fd);
 		return;
 	}
 
@@ -785,10 +797,7 @@ extract_tiff (const gchar          *uri,
 	tracker_exif_free (ed);
 	tracker_xmp_free (xd);
 	tracker_iptc_free (id);
-
-	if (mfile) {
-		tracker_file_close (mfile, FALSE);
-	}
+	close (fd);
 }
 
 TrackerExtractData *



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