Lines Matching refs:dir
21 #include <isc/dir.h>
31 #define VALID_DIR(dir) ISC_MAGIC_VALID(dir, ISC_DIR_MAGIC)
34 isc_dir_init(isc_dir_t *dir) {
35 REQUIRE(dir != NULL);
37 dir->entry.name[0] = '\0';
38 dir->entry.length = 0;
40 dir->handle = NULL;
42 dir->magic = ISC_DIR_MAGIC;
50 isc_dir_open(isc_dir_t *dir, const char *dirname) {
54 REQUIRE(VALID_DIR(dir));
61 if (strlen(dirname) + 3 > sizeof(dir->dirname)) {
65 strlcpy(dir->dirname, dirname, sizeof(dir->dirname));
70 p = dir->dirname + strlen(dir->dirname);
71 if (dir->dirname < p && *(p - 1) != '/')
79 dir->handle = opendir(dirname);
81 if (dir->handle == NULL) {
93 * the dir stream and reads the first file in one operation.
96 isc_dir_read(isc_dir_t *dir) {
99 REQUIRE(VALID_DIR(dir) && dir->handle != NULL);
104 entry = readdir(dir->handle);
112 if (sizeof(dir->entry.name) <= strlen(entry->d_name))
115 strlcpy(dir->entry.name, entry->d_name, sizeof(dir->entry.name));
120 dir->entry.length = strlen(entry->d_name);
129 isc_dir_close(isc_dir_t *dir) {
130 REQUIRE(VALID_DIR(dir) && dir->handle != NULL);
132 (void)closedir(dir->handle);
133 dir->handle = NULL;
140 isc_dir_reset(isc_dir_t *dir) {
141 REQUIRE(VALID_DIR(dir) && dir->handle != NULL);
143 rewinddir(dir->handle);