ID:               33047
 Comment by:       rele at gmx dot de
 Reported By:      wiseman1024 at gmail dot com
 Status:           No Feedback
 Bug Type:         Directory function related
 Operating System: Windows 2000
 PHP Version:      4.3.9
 New Comment:

This bug has still not been fixed, I tested it with PHP 5.2.4 on WinXP
SP 2.

In addition the bug occurs when the glob pattern parameter contains a
directory path containing non-empty brackets.

And in contrary to the workaround mentioned in the manual, escaping
does not change anything.
http://www.php.net/manual/en/function.glob.php#76621


chdir('C:\\');
$dir = 'C:\a[test]';
$dir_escaped = 'C:\a\[test\]';
print_r(glob($dir . DIRECTORY_SEPARATOR . '*'));
print_r(glob($dir_escaped . DIRECTORY_SEPARATOR . '*'));


Previous Comments:
------------------------------------------------------------------------

[2006-02-16 23:52:50] ian at res-alian dot com

Argh. I forgot to add sort($picfns) for good measure, since readdir()
returns entries in the order they appear on the hard drive while glob()
returns them sorted (unless using the GLOB_NOSORT flag). If the PHP
developers fix the glob() Win32 bug, I can stop ranting.... =)

--i;

------------------------------------------------------------------------

[2006-02-16 23:19:14] ian at res-alian dot com

Here's my workaround code, using opendir() and readdir() (using code
from the readdir() page on this site):

    if ($dirh = opendir("."))
    {
      $picfns = 0;

      while (false !== ($file = readdir($dirh)))
      {
        if (preg_match("/^_.*jpg$/", $file))
        {
          $file = preg_replace("/^_/", "", $file);

          if ($picfns)
          {
            array_push($picfns, $file);
          }
          else
          {
            $picfns = array($file);
          }
        }
      }

      closedir($dirh);
    }

replaces this code:

    $thumbfns = glob("_*.jpg");
    $jpgfns = glob("*.jpg");
    $picfns = array_diff($jpgfns, $thumbfns);

--i;

------------------------------------------------------------------------

[2006-02-16 18:41:20] ian at res-alian dot com

I get the same problem with glob() using PHP 5.0.2 and 5.1.2 in Windows
2000 (my work computer, NTFS) and in Windows XP (notebook, 5.0.5, NTFS)
but not Linux (server, 5.0.2, ext3). Sorry I can't offer a solution
other than using Linux. I'm not sure if it has to do with the NTFS file
system.

It took me a while to figure out why some folders didn't work, and I
thought it was a permission thing. When I noticed the folder that worked
had no bracket, I tried adding brackets, and that made it not work.
(Also removing the brackets made ones with brackets suddenly work.) Then
I knew what to look for and found this bug entry with Google.

What's strange is that glob() has no problem returning a list with some
entries containing brackets, but not any entries at all when within a
folder with brackets.

The other strange thing is the opendir() and readdir() work fine in the
same situation under Windows. It's more inconvenient but serves as a
workaround.

--i;

------------------------------------------------------------------------

[2005-05-25 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2005-05-17 20:47:36] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/33047

-- 
Edit this bug report at http://bugs.php.net/?id=33047&edit=1

Reply via email to