+static char *path_append(const char *dir, const char *path)
+{
+ char *result;
+
+ result = malloc(strlen(dir) + 1 + strlen(path) + 1);
+
+ strcpy(result, dir);
+ strcat(result, "/");
+ strcat(result, path);
+
+ return result;
+}
+
+static char **paths_add(char **paths, int n, char *path)
+{
+ char **result;
+
+ result = malloc((n+1) * sizeof(void *));
+
+ memcpy(result + 1, paths, n * sizeof(void *));
+
+ *result = path;
+
+ return result;
+}
+
+char **dir_list(const char *dpath, int (*filter) (const char *))