Книга: Programming with POSIX® Threads

6.5.2 Directory searching

6.5.2 Directory searching

int readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result);

This function performs essentially the same action as readdir. That is, it returns the next directory entry in the directory stream specified by dirp. The difference is that instead of returning a pointer to that entry, it copies the entry into the buffer specified by entry. On success, it returns 0 and sets the pointer specified by result to the buffer entry. On reaching the end of the directory stream, it returns 0 and sets result to NULL. On failure, it returns an error number such as

EBADF.

Refer to program pipe .c, in Section 4.1, for a demonstration of using readdir_r to allow your threads to search multiple directories concurrently.

Оглавление книги


Генерация: 1.519. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз