[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH master f15-branch] Fix the logic surrounding use of the filterfunc for get_file_list (#691880).
- From: Chris Lumens <clumens redhat com>
- To: anaconda-devel-list redhat com
- Subject: [PATCH master f15-branch] Fix the logic surrounding use of the filterfunc for get_file_list (#691880).
- Date: Tue, 29 Mar 2011 15:31:29 -0400
Everywhere this function is used, we expect that a return value of 1 means
"include the entry" and 0 means "omit it". However, that's not how
get_file_list behaves. So fix it to do so, and then document the behavior.
---
loader/dirbrowser.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/loader/dirbrowser.c b/loader/dirbrowser.c
index ba0a6e8..18d6cdb 100644
--- a/loader/dirbrowser.c
+++ b/loader/dirbrowser.c
@@ -53,6 +53,13 @@ static int simpleStringCmp(const void * a, const void * b) {
#define FSTEP 10
+/* Return a list of the contents of a directory, non-recursively.
+ *
+ * dirname -- The directory to list.
+ * filterfunc -- An optional function to use for filtering out the results.
+ * If this function returns 1, the directory is included.
+ * Otherwise, it is omitted.
+ */
char ** get_file_list(char * dirname, filterfunc_t filterfunc) {
DIR * dir;
struct dirent *entry;
@@ -72,7 +79,7 @@ char ** get_file_list(char * dirname, filterfunc_t filterfunc) {
continue;
if ((strlen(entry->d_name) == 2) && !strncmp(entry->d_name, "..", 2))
continue;
- if (filterfunc && filterfunc(dirname, entry))
+ if (filterfunc && !filterfunc(dirname, entry))
continue;
files[i] = strdup(entry->d_name);
--
1.7.4.1
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]