in reply to readdir() on a sysopen() handle?
Looking through several linux man pages, it looks like you normally should use opendir, readdir or scandir, and closedir from C. Those functions are specified by POSIX and are portable. But the glibc also offers fdopendir that converts a plain integer file descriptor to a DIR *. So in C, something like this should work:
/* UNTESTED! */ DIR * d opendir_nofollow(const char * pathname) { int fd = open(pathname, O_DIRECTORY | O_NOFOLLOW); if (fd == -1) { return NULL; } return fdopendir(fd); }
Converting that to a perl directory handle will very likely require a little bit of XS code. Perhaps Inline::C might be helpful. You definitively want to have a look at the perl sources, the part that implements the opendir function, to see how to correctly create a directory handle.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: readdir() on a sysopen() handle?
by haukex (Archbishop) on Aug 20, 2017 at 14:25 UTC | |
by ikegami (Patriarch) on Aug 21, 2017 at 04:20 UTC | |
by haukex (Archbishop) on Aug 21, 2017 at 08:43 UTC | |
by ikegami (Patriarch) on Aug 21, 2017 at 19:04 UTC | |
by afoken (Chancellor) on Aug 22, 2017 at 05:29 UTC |