|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-02-11 03:17 UTC] pilhoon at gmail dot com
Description:
------------
scandir duplicates file name at every 65535th file
Reproduce code:
---------------
I made over 260000 files in a folder.
Their names are 'f100001' ... 'f264001'.
$file_names = scandir('files/');
$base_names= array();
for($i=100001; $i<=263064; $i++)
{
$base_names["f".$i] = 0;
}
foreach($file_names as $a_name)
{
if(1 == $base_names[$a_name])
echo $a_name."\n";
else
$base_names[$a_name] = 1;
}
Expected result:
----------------
They must be showed only once.
Actual result:
--------------
scandir(THAT_FOLDER) returns large array but
f165534 and f231069 are duplicated.
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
Same problem reproduced PHP Version 5.4.4 Windows 7 x64 PHP Version 5.3.13 Windows 7 x32 But all PHP methods listing files are affected scandir, glob, DirectoryIterator. Reproduce code: --------------- // Settings $dir = './test/'; $totalFiles = 1e5; // Create empty files !is_dir($dir) && mkdir($dir); for ($i = 0; $i < $totalFiles; ++$i) { $filename = $dir . str_pad($i, 6, '0', STR_PAD_LEFT); touch($filename); } // Glob $files = glob($dir . '*'); echo 'glob: ' . count($files) . '/' . $totalFiles . PHP_EOL; // Scandir $files = scandir($dir); echo 'scandir: ' . (count($files) - 2) . '/' . $totalFiles . PHP_EOL; // . and .. // DirectoryIterator $it = new DirectoryIterator($dir); echo 'DirectoryIterator: ' . (iterator_count($it) - 2) . '/' . $totalFiles . PHP_EOL; // . and .. unset($it); Expected result: ---------------- glob: 100000/100000 scandir: 100000/100000 DirectoryIterator: 100000/100000 Actual result: -------------- glob: 100001/100000 scandir: 100001/100000 DirectoryIterator: 100001/100000