doushang7209 2016-03-27 17:00
浏览 36

PHP DirectoryIterator在Windows上缺少目录

I'm making module to get list of directories in specified path using PHP DirectoryIterator. There is example:

class GardenUtils
{
    public static function getPath()
    {
        return public_path() . "/images/garden/";
    }

    public static function getAlbumDirectories()
    {
        $directories = [];

        $directoryIterator = new DirectoryIterator(self::getPath());

        foreach ($directoryIterator as $directory) {
            if (!$directory->isDot() && $directory->isDir()) {
                $directories[] = FileUtil::normalizeFileName($directory->getFilename());
            }
        }

        return $directories;
    }
}

My problem is a result of scanning in the array are missing some of the directory. For example - 12 are placed in the directory, and fall into the array 10. If i remove $directory->isDir() condition, all files will be scanned. In addition, if i call $directory->getType(), script crashing with RuntimeException. All directories contains Russian letters and diacritics.

Example of name that scanned correctly: Аквилегия (Aquilégia)
Example of name, that cause problems: Хоста (Hósta) (h5-30)

That problem reproduced with PHP 5.6.12 on Windows 7 with Russian locale. PHP 5.5.25 on Linux system works correctly.

How can i solve it?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 个人网站被恶意大量访问,怎么办
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序