[tracker] tracker-miner-fs: Reworked 0.6 patch from NB#147027 for 0.7.



commit 70eff85b5f8463410ff96918be765d0d7abdaf74
Author: Martyn Russell <martyn lanedo com>
Date:   Fri Jan 15 15:27:25 2010 +0000

    tracker-miner-fs: Reworked 0.6 patch from NB#147027 for 0.7.
    
    This adds Windows hidden directory checking by looking at the file
    attributes. Unfortunately GIO only supports this if we are running on
    Windows and does it differently too using the GetFileAttributesW()
    API.
    
    See commit c69e69c906eb8c903b515a6782c76efc8aa9f8e6.

 src/tracker-miner-fs/tracker-miner-files.c |   35 ++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/src/tracker-miner-fs/tracker-miner-files.c b/src/tracker-miner-fs/tracker-miner-files.c
index dd12fce..a271e47 100644
--- a/src/tracker-miner-fs/tracker-miner-files.c
+++ b/src/tracker-miner-fs/tracker-miner-files.c
@@ -20,8 +20,13 @@
 #include "config.h"
 
 #include <sys/statvfs.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/msdos_fs.h>
+#include <unistd.h>
 
 #include <glib/gi18n.h>
+#include <glib/gstdio.h>
 
 #include <libtracker-common/tracker-ontology.h>
 #include <libtracker-common/tracker-power.h>
@@ -986,7 +991,7 @@ miner_files_check_file (TrackerMinerFS *fs,
 
 	should_process = TRUE;
 
- done:
+done:
 	g_free (basename);
 	g_free (path);
 
@@ -1007,6 +1012,7 @@ miner_files_check_directory (TrackerMinerFS *fs,
 	gchar *basename;
 	gchar *path;
 	gboolean should_process;
+	gboolean is_hidden;
 
 	should_process = FALSE;
 	basename = NULL;
@@ -1019,7 +1025,32 @@ miner_files_check_directory (TrackerMinerFS *fs,
 
 	path = g_file_get_path (file);
 
-	if (file_info && g_file_info_get_is_hidden (file_info)) {
+	/* First we check the GIO hidden check. This does a number of
+	 * things for us which is good (like checking ".foo" dirs).
+	 */
+	is_hidden = file_info && g_file_info_get_is_hidden (file_info);
+
+	/* Second we check if the file is on FAT and if the hidden
+	 * attribute is set. GIO does this but ONLY on a Windows OS,
+	 * not for Windows files under a Linux OS, so we have to check
+	 * anyway.
+	 */
+	if (!is_hidden) {
+		int fd;
+
+		fd = g_open (path, O_RDONLY, 0);
+		if (fd != -1) {
+			__u32 attrs;
+
+			if (ioctl (fd, FAT_IOCTL_GET_ATTRIBUTES, &attrs) == 0) {
+				is_hidden = attrs & ATTR_HIDDEN ? TRUE : FALSE;
+			}
+
+			close (fd);
+		}
+	}
+
+	if (is_hidden) {
 		TrackerMinerFiles *mf;
 		GSList *allowed_directories;
 



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