[PHP-DEV] Bug #1627: Opendir does not behave the same on Windows platform as on Unix(Linux) From: fredm <email protected>
Date: 06/29/99

From: fredm <email protected>
Operating system: Win NT 4 SP5
PHP version: 3.0 Latest CVS (29/06/1999)
PHP Bug Type: Misbehaving function
Bug description: Opendir does not behave the same on Windows platform as on Unix(Linux)

I use the following code to test for the existance of a directory
if($rc = opendir($directory)) {
   /* Perform code for directory exists */
else {
   /* Create directory and do create processing */
}
This code works fine on Linux but always gives a good return even if the directory does not exist on Windows.
Looking in readir.c i see the following code
if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) {
     if (errno == ENOENT)
        dp->finished = 1; <-- I'm not sure what this is supposed to do
     else
        return NULL;
}
It seems that the function is to behave differently if the file does not exist, than if there is an error in the file
spec. If I comment out the check for enoent, and return null if the file does not exist, and recompile, my
code works identically on Windows and Linux.

 If I was sure of why the code was originally set up like it is, I'd have a go at fixing it, even with my very rusty
C, but I guess I need to mess around a little more with the source, and watch how you guys do it, before I
push the boat out.

Best regards. . . Fred
 

-- 
PHP Development Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>