hal/hald device_info.c,1.8,1.9

David Zeuthen david at pdx.freedesktop.org
Sun Jul 4 12:20:02 PDT 2004


Update of /cvs/hal/hal/hald
In directory pdx:/tmp/cvs-serv30241/hald

Modified Files:
	device_info.c 
Log Message:
2004-07-04  David Zeuthen  <david at fubar.dk>

	* hald/device_info.c (scan_fdi_files): Use glib to determine
	the file type since d_type in struct dirent can be DT_UNKNOWN



Index: device_info.c
===================================================================
RCS file: /cvs/hal/hal/hald/device_info.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- device_info.c	3 Apr 2004 07:46:33 -0000	1.8
+++ device_info.c	4 Jul 2004 19:20:00 -0000	1.9
@@ -592,7 +592,7 @@
 
 	found_fdi_file = 0;
 
-	/*HAL_INFO(("scan_fdi_files: Processing dir '%s'", dir)); */
+	HAL_INFO(("scan_fdi_files: Processing dir '%s'", dir));
 
 	num_entries = scandir (dir, &name_list, 0, alphasort);
 	if (num_entries == -1) {
@@ -603,11 +603,18 @@
 	for (i = num_entries - 1; i >= 0; i--) {
 		int len;
 		char *filename;
+		gchar *full_path;					     
 
 		filename = name_list[i]->d_name;
 		len = strlen (filename);
 
-		if (name_list[i]->d_type == DT_REG) {
+		full_path = g_strdup_printf ("%s/%s", dir, filename);
+		HAL_INFO (("Full path = %s", full_path));
+
+		/* Mmm, d_type can be DT_UNKNOWN, use glib to determine
+		 * the type
+		 */
+		if (g_file_test (full_path, (G_FILE_TEST_IS_REGULAR))) {
 			/* regular file */
 
 			if (len >= 5 &&
@@ -626,8 +633,8 @@
 				}
 			}
 
-		} else if (name_list[i]->d_type == DT_DIR &&
-			   strcmp (filename, ".") != 0
+		} else if (g_file_test (full_path, (G_FILE_TEST_IS_DIR)) 
+			   && strcmp (filename, ".") != 0
 			   && strcmp (filename, "..") != 0) {
 			int num_bytes;
 			char *dirname;
@@ -652,6 +659,8 @@
 				break;
 		}
 
+		g_free (full_path);
+
 		free (name_list[i]);
 	}
 





More information about the hal-commit mailing list