Forráskód Böngészése

Add G_set_ls_exclude_filter()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34405 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 éve
szülő
commit
534fe54205
2 módosított fájl, 12 hozzáadás és 0 törlés
  1. 1 0
      include/gisdefs.h
  2. 11 0
      lib/gis/ls.c

+ 1 - 0
include/gisdefs.h

@@ -707,6 +707,7 @@ char *G__location_path(void);
 
 /* ls.c */
 void G_set_ls_filter(int (*)(const char *, void *), void *);
+void G_set_ls_exclude_filter(int (*)(const char *, void *), void *);
 char **G__ls(const char *, int *);
 void G_ls(const char *, FILE *);
 void G_ls_format(char **, int, int, FILE *);

+ 11 - 0
lib/gis/ls.c

@@ -33,6 +33,9 @@ typedef int ls_filter_func(const char * /*filename */ , void * /*closure */ );
 static ls_filter_func *ls_filter;
 static void *ls_closure;
 
+static ls_filter_func *ls_ex_filter;
+static void *ls_ex_closure;
+
 static int cmp_names(const void *aa, const void *bb)
 {
     char *const *a = (char *const *)aa;
@@ -60,6 +63,12 @@ void G_set_ls_filter(ls_filter_func *func, void *closure)
     ls_closure = closure;
 }
 
+void G_set_ls_exclude_filter(ls_filter_func *func, void *closure)
+{
+    ls_ex_filter = func;
+    ls_ex_closure = closure;
+}
+
 /**
  * \brief Stores a sorted directory listing in an array
  * 
@@ -91,6 +100,8 @@ char **G__ls(const char *dir, int *num_files)
 	    continue;
 	if (ls_filter && !(*ls_filter)(dp->d_name, ls_closure))
 	    continue;
+	if (ls_ex_filter && (*ls_ex_filter)(dp->d_name, ls_ex_closure))
+	    continue;
 	dir_listing = (char **)G_realloc(dir_listing, (1 + n) * sizeof(char *));
 	dir_listing[n] = G_store(dp->d_name);
 	n++;