问题描述
在Windows系统上,备份代理创建的临时隐藏文件与原始文件的名称几乎相同,并且路径相同.这可能会干扰使用PHP scandir()
的进程.
On a Windows system, a backup agent created temporary hidden files of nearly the same name as the original files, and in the same path. This was probably disturbing a process that used PHP scandir()
.
现在,我想知道Windows上具有隐藏标志集的文件是否被PHP scandir()
排除.
Now I was wondering if files on Windows having the hidden flag set are excluded by PHP scandir()
.
有些文章介绍了Linux风格的隐藏文件,scandir()
如何忽略以点开头的文件,但很少有有关Windows文件的信息.
There are some articles about the hidden files in Linux style, how scandir()
should ignore files that start with a dot, but there is rarely no info about Windows files.
推荐答案
简短的测试表明,scandir()
,glob()
或其他都不会处理隐藏的标志.
A short test shows that neither scandir()
nor glob()
or others take care of the hidden flag.
这是实验和结果:
零件:
- Windows 7
- PHP 5.6.9(x86)
- Visual Studio 2012可再发行的x86
因此scandir()
不会隐藏设置了隐藏标志的文件.
So scandir()
does not hide files having the hidden flag set.
下一个问题是,是否可以配置功能更强大的PHP命令,例如glob()
.
Next question is, can more powerful PHP commands like glob()
be configured.
首先,没有用于处理标志的参数:
Firstly, there is no parameter to deal with flags:
http://php.net/manual/de/function.glob.php
其次,加布里埃尔·卢拉斯基(Gabriel S. Luraschi)的这句话很有说服力:
Secondly, there is this telling comment of Gabriel S. Luraschi:
http://php.net/manual/de/function.glob .php#110510
他推荐exec('dir ... \A ...')
.但是在商业托管(如果它们在Windows上运行)上,将不允许这样做.
He recommends exec('dir ... \A ...')
. But on commercial hostings (if they run on Windows), this will not be allowed.
请确保:使用Linux样式,并忽略以点开头的文件,例如:
To be sure: use the Linux style and ignore files that start with a dot, like here:
这篇关于php scandir()是否排除Windows下的隐藏文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!