1#ifndef INCLUDE_INTERFACES_FSI_DIRUTILS_POSIX_H_
2#define INCLUDE_INTERFACES_FSI_DIRUTILS_POSIX_H_
5# define __FSI_DIRUTILS_POSIX_CPP_OPEN extern "C" {
6# define __FSI_DIRUTILS_POSIX_CPP_CLOSE }
8# define __FSI_DIRUTILS_POSIX_CPP_OPEN
9# define __FSI_DIRUTILS_POSIX_CPP_CLOSE
82 if (fstatat(dirfd, e->d_name, &st, AT_SYMLINK_NOFOLLOW) == 0)
84 if (S_ISREG(st.st_mode))
return FSI_FILE;
85 if (S_ISDIR(st.st_mode))
return FSI_DIR;
102 if (fstatat(dirfd, e->d_name, stOut, AT_SYMLINK_NOFOLLOW) == 0)
110 if (fstatat(dirfd, e->d_name, stOut, AT_SYMLINK_NOFOLLOW) == 0)
112 if (S_ISDIR(stOut->st_mode))
return FSI_DIR;
113 if (S_ISREG(stOut->st_mode))
return FSI_FILE;
122 for (
size_t i = 0 ; i < v->size ; i++)
128 if (e->
dev == dev && e->
ino == ino)
152 int fd = open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
155 DIR *dir = fdopendir(fd);
164 if (fstat(fd, &dirSt) != 0)
179 CSTR tmp = cstr_init();
181 while ((e = readdir(dir)))
183 if (e->d_name[0] ==
'.' &&
184 (e->d_name[1] ==
'\0' || (e->d_name[1] ==
'.' && e->d_name[2] ==
'\0')))
191 cstr_set(&tmp, path);
193 cstr_add(&tmp, e->d_name);
195 cvec_push(out,
const char*, CVEC_sys_strdup(tmp.data));
210#undef __FSI_DIRUTILS_POSIX_CPP_OPEN
211#undef __FSI_DIRUTILS_POSIX_CPP_CLOSE
void fsi_closeDir(FSI_DirData *d)
Get the directory data to deallocate memory.
int fsi_openDir(FSI_DirData *d, const char *path)
Open directory as read only.
static void __fsi_walk(CVEC *out, CVEC *visited, const char *path)
static FSI_EntryType fsi_getEntryTypeFromDirent(int dirfd, struct dirent *e, struct stat *stOut)
static int fsi_visitedHas(CVEC *v, dev_t dev, ino_t ino)
#define __FSI_DIRUTILS_POSIX_CPP_CLOSE
static void fsi_visitedAdd(CVEC *v, dev_t dev, ino_t ino)
static FSI_EntryType fsi_getEntryType(int dirfd, struct dirent *e)
Get the entry type of the dirfd from the FSI_DirData_POSIX.
int fsi_readDir(FSI_DirData *d, FSI_EntryData *out)
Read directory from reading the FSI_DirData information.
#define __FSI_DIRUTILS_POSIX_CPP_OPEN