PHP 4.3.10_2 readdir() misses files
YONETANI Tomokazu
qhwt+dfly at les.ath.cx
Mon Feb 7 18:14:47 PST 2005
On Mon, Feb 07, 2005 at 09:28:50PM +0100, Devon H. O'Dell wrote:
> On Mon, 2005-02-07 at 20:27 +0100, Joerg Anslik wrote:
> > <?php
> > if(($dh = @opendir("/tmp/phptest")) == false) {
> >
> > print "No such dir!\n";
> >
> > exit;
> > }
> >
> > while($entry = readdir($dh)) {
> >
> > print "[$entry]\n";
> > }
> >
> > closedir($dh);
> > ?>
>
> With the latest current ISO, I also experience this behavior. I will
> take a closer look at it tomorrow.
php uses readdir_r(), and the following code exhibits the same
problem as php-cli:
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#if 1
#define READDIR(dir, ent, resultp) readdir_r(dir, &ent, &resultp), resultp
#else
#define READDIR(dir, ent, resultp) (void)ent, (resultp = readdir(dir))
#endif
int
main(void)
{
DIR *dir;
struct dirent *e, ent;
if ((dir = opendir(".")) == NULL) {
perror("opendir");
return 1;
}
while (READDIR(dir, ent, &e) != NULL)
printf("%s\n", e->d_name);
closedir(dir);
return 0;
}
More information about the Users
mailing list