sort_dir.h File Reference
Detailed Description
Obtain a sorted directory listing.
The prototype of sort_dir is a little scary, but it is easy to use. For example, to sort a given directory alphabetically:
char **list;
int i;
sort_dir(dirname,&list,strcmp);
for(i=0;list[i];i++) printf("%s\n",list[i]);
sort_dir_free(list);
Go to the source code of this file.
|
Functions |
int | sort_dir (const char *dirname, char ***list, int(*sort)(const char *a, const char *b)) |
| Obtain a sorted directory listing.
|
void | sort_dir_free (char **list) |
| Free a sorted directory listing.
|
Function Documentation
int sort_dir |
( |
const char * |
dirname, |
|
|
char *** |
list, |
|
|
int(*)(const char *a, const char *b) |
sort |
|
) |
|
|
|
Obtain a sorted directory listing.
- Parameters:
-
| dirname | The directory to list. |
| list | A pointer to a doubly-indirect pointer, which will be filled with a list of strings. The final item will be null. This list must be freed with sort_dir_free. |
| sort | A pointer to a function to compare two strings, which must have the same semantics as strcmp |
- Returns:
- True on success, false on failure, setting errno appropriately.
|
void sort_dir_free |
( |
char ** |
list |
) |
|
|
|
Free a sorted directory listing.
- Parameters:
-
| list | The list to be freed. |
|
Generated on Fri Jun 4 09:58:46 2010 for cctools by
1.3.9.1