Directory enumerator header file. More...
#include <dirent.h>
#include "global.h"
Go to the source code of this file.
Defines | |
#define | ESTIMATED_ENTRY_LENGTH (15) |
How many bytes an average filename needs. | |
Functions | |
int | dir__enumerator (struct estat *this, int est_count, int by_name) |
This function reads a directory into a self-allocated memory area. | |
int | dir__sortbyname (struct estat *sts) |
Sorts the entries of the directory sts by name into the estat::by_name array, which is reallocated and NULL-terminated. | |
int | dir__sortbyinode (struct estat *sts) |
Sorts the existing estat::by_inode array afresh, by device/inode. | |
int | dir___f_sort_by_inode (struct estat **a, struct estat **b) |
Compares the data inside two struct estat pointers to pointers by device/inode. | |
int | dir___f_sort_by_inodePP (struct estat *a, struct estat *b) |
Compares two struct estat pointers by device/inode. | |
int | dir___f_sort_by_name (const void *a, const void *b) |
Compares the data inside two struct estat pointers to pointers by name. | |
int | dir___f_sort_by_nameCC (const void *a, const void *b) |
Compares two names/strings. | |
int | dir___f_sort_by_nameCS (const void *a, const void *b) |
Compares a pointer to name (string) with a struct estat pointer to pointer. |
Directory enumerator header file.
Definition in file direnum.h.
#define ESTIMATED_ENTRY_LENGTH (15) |
How many bytes an average filename needs.
Measured on a debian system:
find / -printf "%f\n" | wc
Definition at line 43 of file direnum.h.
Referenced by dir__enumerator().
Compares the data inside two struct estat pointers to pointers by device/inode.
Definition at line 252 of file direnum.c.
References dir___f_sort_by_inodePP().
Referenced by dir__sortbyinode(), ops__find_entry_byinode(), waa___find_position(), and waa__output_tree().
Compares two struct estat pointers by device/inode.
That is now an inline function; but without force gcc doesn't inline it on 32bit, because of the size (64bit compares, 0x6b bytes). [ __attribute__
((always_inline)) in declaration].
Definition at line 235 of file direnum.c.
References sstat_t::dev, sstat_t::ino, and estat::st.
Referenced by dir___f_sort_by_inode(), and ign__is_ignore().
int dir___f_sort_by_name | ( | const void * | a, | |
const void * | b | |||
) |
Compares the data inside two struct estat pointers to pointers by name.
Definition at line 271 of file direnum.c.
References dir___f_sort_by_nameCC().
Referenced by dir__sortbyname(), and ops__correlate_dirs().
int dir___f_sort_by_nameCC | ( | const void * | a, | |
const void * | b | |||
) | [inline] |
Compares two names/strings.
Used for type checking cleanliness. 'C' as for 'Const'.
Definition at line 262 of file direnum.c.
Referenced by dir___f_sort_by_name(), and dir___f_sort_by_nameCS().
int dir___f_sort_by_nameCS | ( | const void * | a, | |
const void * | b | |||
) |
Compares a pointer to name (string) with a struct estat pointer to pointer.
Definition at line 283 of file direnum.c.
References dir___f_sort_by_nameCC().
Referenced by ops__find_entry_byname().
int dir__enumerator | ( | struct estat * | this, | |
int | est_count, | |||
int | give_by_name | |||
) |
This function reads a directory into a self-allocated memory area.
This function reads a directory into a self-allocated memory area.
The entries are sorted by inode number and stat()ed.
this | a pointer to this directory's stat - for estimating the number of entries. Only this->st.st_size is used for that - it may have to be zeroed before calling. | |
est_count | is used to give an approximate number of entries, to avoid many realloc()s. | |
give_by_name | simply tells whether the ->by_name array should be created, too. |
The result is written back into the sub-entry array in this.
To avoid reallocating (and copying!) large amounts of memory, this function fills some arrays from the directory, then allocates the needed space, sorts the data (see note below) and adds all other data. See sts_array, names and inode_numbers.
Definition at line 361 of file direnum.c.
References BUG_ON, estat::by_inode, estat::by_name, DEBUGP, dir__close(), dir__enum(), dir__get_dir_size(), dir__sortbyinode(), dir__sortbyname(), dir__start_enum(), estat::entry_count, ESTIMATED_ENTRY_LENGTH, FREE_SPACE, hlp__alloc(), hlp__lstat(), hlp__realloc(), IF_FREE, sstat_t::ino, estat::local_mode_packed, sstat_t::mode, MODE_T_to_PACKED, estat::name, estat::old_rev_mode_packed, ops__allocate(), estat::parent, estat::repos_rev, sstat_t::size, estat::st, STOPIF, STOPIF_CODE_ERR, estat::strings, and estat::to_be_ignored.
Referenced by waa__dir_enum().
int dir__sortbyinode | ( | struct estat * | sts | ) |
Sorts the existing estat::by_inode array afresh, by device/inode.
Definition at line 322 of file direnum.c.
References BUG_ON, estat::by_inode, dir___f_sort_by_inode(), and estat::entry_count.
Referenced by dir__enumerator(), ops__find_entry_byinode(), and waa__output_tree().
int dir__sortbyname | ( | struct estat * | sts | ) |
Sorts the entries of the directory sts by name into the estat::by_name array, which is reallocated and NULL-terminated.
Sorts the entries of the directory sts by name into the estat::by_name array, which is reallocated and NULL-terminated.
If it has no entries, an array with NULL is nonetheless allocated.
Definition at line 293 of file direnum.c.
References estat::by_inode, estat::by_name, dir___f_sort_by_name(), estat::entry_count, hlp__realloc(), and STOPIF.
Referenced by dir__enumerator(), ops__correlate_dirs(), ops__find_entry_byname(), and waa__do_sorted_tree().