Bug #1627: Opendir does not behave the same on Windows platform as on Unix(Linux)
| From: | fredm at esoterica dot pt | Date: | Tue, 29 Jun 1999 19:38:12 +0000 |
| Subject: | Bug #1627: Opendir does not behave the same on Windows platform as on Unix(Linux) | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-7836@lists.php.net to get a copy of this message | ||
From: fredm@esoterica.pt
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