getdents - read directory entries and put in a file system independent format
#include <dirent.h> int getdents(int fildes, struct dirent *buf, size_t nbyte);
The getdents() function attempts to read nbyte bytes from the directory associated with the file descriptor fildes and to format them as file system independent directory entries in the buffer pointed to by buf. Since the file system independent directory entries are of variable lengths, in most cases the actual number of bytes returned will be less than nbyte. The file system independent directory entry is specified by the dirent structure. See dirent.h(3HEAD).
On devices capable of seeking, getdents() starts at a position in the file given by the file pointer associated with fildes. Upon return from getdents(), the file pointer is incremented to point to the next directory entry.
Upon successful completion, a non-negative integer is returned indicating the number of bytes actually read. A return value of 0 indicates the end of the directory has been reached. Otherwise, -1 is returned and errno is set to indicate the error.
The getdents() function will fail if:
EBADF
EFAULT
EINVAL
EIO
ENOENT
ENOLINK
ENOTDIR
EOVERFLOW
The getdents() function was developed to implement the readdir(3C) function and should not be used for other purposes.
The getdents() function has a transitional interface for 64-bit file offsets. See lf64(5).
readdir(3C), dirent.h(3HEAD), lf64(5)
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |