18 #include <sys/types.h>
34 static int cmp_dirent(
const void *,
const void *);
35 static int get_perm(
char *);
36 static void sort_dirent(
dbDirent *,
int);
61 dp = opendir(dirname);
70 while ((entry = readdir(dp))) {
72 len = strlen(entry->d_name);
89 for (i = 0; i <
count; i++) {
96 sprintf(
path,
"%s/%s", dirname, entry->d_name);
119 for (i = 0; i <
count; i++)
125 static int get_perm(
char *
path)
141 static int cmp_dirent(
const void *aa,
const void *bb)
150 static void sort_dirent(
dbDirent *a,
int n)
152 qsort(a, n,
sizeof(
dbDirent), cmp_dirent);
172 for (i = 0; i <
count; i++)
int db_isdir(const char *)
Test if path is a directory.
void * db_calloc(int, int)
Allocate memory.
void db_clear_error(void)
Clear error status.
void db_free_string(dbString *)
Free allocated space for dbString.
int db_set_string(dbString *, const char *)
Inserts string to dbString (enlarge string)
void db_free(void *)
Free allocated memory.
void db_init_string(dbString *)
Initialize dbString.
void db_syserror(const char *)
Report system error.
char * db_get_string(const dbString *)
Get string.
void * db_malloc(int)
Allocate memory.
dbDirent * db_dirent(const char *dirname, int *n)
Read directory and build an array of dbDirent's.
dbDirent * db_alloc_dirent_array(int count)
Allocate dirent array.
void db_free_dirent_array(dbDirent *db_dirent, int count)
Free dbDirent.