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.
15
int sort_dir( const char *dirname, char ***list, int (*sort) ( const char *a, const char *b ) )
23
*list = malloc(size*sizeof(char*));
24
if(!*list) goto failure;
26
dir = opendir(dirname);
27
if(!dir) goto failure;
29
while( (d = readdir(dir)) ) {
32
*list = realloc(*list,sizeof(char*)*size);
33
if(!*list) goto failure;
36
s = strdup(d->d_name);
43
qsort( *list, used, sizeof(char*), (void*) sort );
56
if(dir) closedir(dir);
60
void sort_dir_free( char **list )
64
for(i=0;list[i];i++) {
65
if(list[i]) free(list[i]);