summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/tools.c')
-rw-r--r--mdk-stage1/tools.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index 7266409c5..2a50c0ee4 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -27,6 +27,8 @@
#include <string.h>
#include <ctype.h>
#include <stdio.h>
+#include <dirent.h>
+#include <sys/types.h>
#include <zlib.h>
#include "stage1.h"
#include "log.h"
@@ -337,3 +339,22 @@ void add_to_env(char * name, char * value)
env_size++;
my_env[env_size] = NULL;
}
+
+
+char ** list_directory(char * direct)
+{
+ char * tmp[500];
+ int i = 0;
+ struct dirent *ep;
+ DIR *dp = opendir(direct);
+ while (dp && (ep = readdir(dp))) {
+ if (strcmp(ep->d_name, ".") && strcmp(ep->d_name, "..")) {
+ tmp[i] = strdup(ep->d_name);
+ i++;
+ }
+ }
+ if (dp)
+ closedir(dp);
+ tmp[i] = NULL;
+ return memdup(tmp, sizeof(char*) * (i+1));
+}