DragonFly BSD
DragonFly users List (threaded) for 2005-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: PHP 4.3.10_2 readdir() misses files


From: YONETANI Tomokazu <qhwt+dfly@xxxxxxxxxx>
Date: Tue, 8 Feb 2005 11:12:37 +0900

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;
}



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]