Index: lib/ewl_fileselector.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_fileselector.c,v
retrieving revision 1.17
diff -u -r1.17 ewl_fileselector.c
--- lib/ewl_fileselector.c	6 Jul 2005 13:44:39 -0000	1.17
+++ lib/ewl_fileselector.c	8 Jul 2005 08:54:23 -0000
@@ -1,6 +1,7 @@
 #include <Ewl.h>
 #include "ewl_debug.h"
 #include "ewl_macros.h"
+#include <Ecore_File.h>
 
 #include <sys/stat.h>
 #include <stdio.h>
@@ -472,12 +473,13 @@
 {
 	regex_t freg, dreg;
 	Ewl_Fileselector_Data *d;
-	struct dirent *lecture;
-	DIR *rep;
 	struct stat buf;
 	char *name;
 	char *path2;
 	int len;
+	Ecore_List *file_list = NULL;
+	char *listing = NULL;
+	
 
 	if (filter) {
 		if (regcomp(&freg, filter, REG_NOSUB | REG_EXTENDED))
@@ -498,36 +500,34 @@
 		path2[strlen(path)] = '/';
 		path2[strlen(path) + 1] = '\0';
 	}
-
-	rep = opendir(path2);
-	if (!rep) {
-		free(path2);
-		DRETURN(DLEVEL_STABLE);
-	}
+	
+	/* Get directory listing, store, and move to beginning of list */
+	file_list = ecore_file_ls(path2);
+	ecore_list_goto_first(file_list);
 
 	/* Loop over all listings in the directory to build both lists */
-	while ((lecture = readdir(rep))) {
+	while ( (!ecore_list_is_empty(file_list)) &&
+		(!(ecore_list_index(file_list) >= (ecore_list_nodes(file_list)))) && 
+		(listing = strdup((char *)ecore_list_next(file_list))) ) {
+		
 		int match = 0;
 		Ecore_List *add = NULL;
 		regex_t *reg;
-
-		/* Skip over the simple case early */
-		if (!strcmp(lecture->d_name,"..") && !strcmp(path,"/"))
-			continue;
-
+		
 		/* Setup a ful path copy to the listing */
-		len = strlen(path2) + strlen(lecture->d_name) + 1;
-		name = (char *) malloc(sizeof(char) * len);
-		memcpy(name, path2, strlen(path2));
+		len = strlen(path2) + strlen(listing) + 1; 	
+		name = (char *) malloc(sizeof(char) * len); 	
+		memcpy(name, path2, strlen(path2)); 
 		memcpy(name + strlen(path2),
-		       lecture->d_name, strlen(lecture->d_name));
-		name[len - 1] = '\0';
+	        listing, strlen(listing)); 
+		name[len - 1] = '\0'; 
 
 		/* Set to NULL before determining the type of the listing */
 		reg = NULL;
-		if (stat(name, &buf) == 0) {
-			/* Determine the file or directory match */
-			if (S_ISDIR(buf.st_mode) && dlist) {
+		
+		/* Determine type of listing */
+		if(stat(name, &buf) == 0) {
+			if(ecore_file_is_dir(name)) {
 				add = dlist;
 				if (dfilter)
 					reg = &dreg;
@@ -540,14 +540,14 @@
 		}
 
 		/* Determine if this item should be listed */
-		if (!strcmp(lecture->d_name, ".."))
+		if (!strcmp(listing, ".."))
 			match = 1;
-		else if (reg && !regexec(reg, lecture->d_name, 0, NULL, 0))
+		else if (reg && !regexec(reg, listing, 0, NULL, 0))
 			match = 1;
-
+	
 		/* File matches so add it to the listing */
 		if (match && add) {
-			d = ewl_fileselector_data_new(lecture->d_name,
+			d = ewl_fileselector_data_new(listing,
 						      buf.st_size,
 						      buf.st_mtime,
 						      buf.st_mode);
@@ -555,16 +555,20 @@
 		}
 
 		free(name);
+		free(listing);
 	}
-
+	
 	/* Clean up temporary variables */
-	closedir(rep);
 	if (filter)
 		regfree(&freg);
 	if (dfilter)
 		regfree(&dreg);
-	free(path2);
-
+	free(path2);	
+	path2 = NULL;
+	
+	ecore_list_destroy(file_list);
+	file_list = NULL;	
+	
 	return;
 }
 
