php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1627 Opendir does not behave the same on Windows platform as on Unix(Linux)
Submitted: 1999-06-29 15:38 UTC Modified: 1999-06-29 22:45 UTC
From: fredm at esoterica dot pt Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0 Latest CVS (29/06/1999) OS: Win NT 4 SP5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fredm at esoterica dot pt
New email:
PHP Version: OS:

 

 [1999-06-29 15:38 UTC] fredm at esoterica dot pt
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 
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-29 22:45 UTC] jim at cvs dot php dot net
Fixed in CVS.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jul 05 16:00:01 2026 UTC