2
Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3
Copyright (C) 2005- The University of Notre Dame
4
This software is distributed under the GNU General Public License.
5
See the file COPYING for details.
11
/** @file sort_dir.h Obtain a sorted directory listing.
12
The prototype of @ref sort_dir is a little scary, but it is easy to use.
13
For example, to sort a given directory alphabetically:
19
sort_dir(dirname,&list,strcmp);
21
for(i=0;list[i];i++) printf("%s\n",list[i]);
27
/** Obtain a sorted directory listing.
28
@param dirname The directory to list.
29
@param list A pointer to a doubly-indirect pointer, which will be filled with a list of strings.
30
The final item will be null. This list must be freed with @ref sort_dir_free.
31
@param sort A pointer to a function to compare two strings, which must have the same semantics as <tt>strcmp</tt>
32
@return True on success, false on failure, setting errno appropriately.
34
int sort_dir( const char *dirname, char ***list, int (*sort) ( const char *a, const char *b ) );
36
/** Free a sorted directory listing.
37
@param list The list to be freed.
40
void sort_dir_free( char **list );