|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-07-02 03:33 UTC] laruence@php.net
[2012-07-02 03:34 UTC] laruence@php.net
[2012-07-02 03:34 UTC] laruence@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: laruence
[2012-07-02 03:34 UTC] laruence@php.net
[2012-07-09 10:46 UTC] ab@php.net
[2014-10-07 23:23 UTC] stas@php.net
[2014-10-07 23:24 UTC] stas@php.net
[2014-10-07 23:34 UTC] stas@php.net
[2014-10-07 23:34 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
Description: ------------ RecurisveDirectoryIterator skips dot files (. and ..) that appear on the top of directory entries only. Since some file systems (e.g.: ext3, FAT32) doesn't sort directory entries, the behavior of RecursiveDirectoryIterator is inconsistent. RecursiveDirectoryIterator should either always skip dot files, or never skip dot files. Otherwise many developer mistakenly assume that RecurisveDirectoryIterator always skips dot files, and add a bug to their programs. ---- (tested on ext3 file system) # mkdir test # cd test # cat <<\EOF >test.php <?php echo __DIR__ . "\n"; print_r(array_keys(iterator_to_array( new RecursiveDirectoryIterator(__DIR__) ))); EOF (use "-U" option not to sort) # ls -liaU total 16 8314945 drwxr-x--- 8 root root 4096 6月 28 02:15 .. 8315727 drwxr-xr-x 2 root root 4096 6月 28 02:16 . 8315728 -rw-r--r-- 1 root root 114 6月 28 02:16 test.php # php test.php /root/test Array ( [0] => /root/test/test.php ) # touch 1 2 3 4 5 # ls -liaU total 16 8315730 -rw-r--r-- 1 root root 0 6月 28 02:16 2 8315733 -rw-r--r-- 1 root root 0 6月 28 02:16 5 8314945 drwxr-x--- 8 root root 4096 6月 28 02:15 .. 8315727 drwxr-xr-x 2 root root 4096 6月 28 02:16 . 8315728 -rw-r--r-- 1 root root 114 6月 28 02:16 test.php 8315729 -rw-r--r-- 1 root root 0 6月 28 02:16 1 8315731 -rw-r--r-- 1 root root 0 6月 28 02:16 3 8315732 -rw-r--r-- 1 root root 0 6月 28 02:16 4 # php test.php /root/test Array ( [0] => /root/test/2 [1] => /root/test/5 [2] => /root/test/.. [3] => /root/test/. [4] => /root/test/test.php [5] => /root/test/1 [6] => /root/test/3 [7] => /root/test/4 ) (To ensure skippping dot files, construct the RecursiveDirectoryIterator with SKIP_DOTS flag for now.) # cat <<\EOF >test.php <?php echo __DIR__ . "\n"; print_r(array_keys(iterator_to_array( new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS) ))); EOF # php test.php /root/test Array ( [0] => /root/test/2 [1] => /root/test/5 [2] => /root/test/test.php [3] => /root/test/1 [4] => /root/test/3 [5] => /root/test/4 )