- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在 Windows 系统上,备份代理创建了与原始文件名称几乎相同且路径相同的临时隐藏文件。这可能会干扰使用 PHP scandir()
的进程。
现在我想知道 Windows 上设置了隐藏标志的文件是否被 PHP scandir()
排除。
有一些关于 Linux 风格的隐藏文件的文章,scandir()
应该如何忽略以点开头的文件,但很少没有关于 Windows 文件的信息。
最佳答案
我已经在 Windows 7 和 Windows 8 & 8.1 上尝试过这段代码,它确实通过标记出来排除了隐藏文件。
<?php
$location="path/to/a/folder/";
if( function_exists("scandir") ){
$file = scandir($location);
foreach($file as $this_file) {
/***Putting the condition here restricts hidden files and files starting with '.' and '~'...****/
if (is_hidden_file($location.$this_file) || $this_file == '.' || $this_file == '..' || $this_file[0]=='.' || $this_file[0]=='~' )
continue;
else {
var_dump($this_file);
}
}
}
function is_hidden_file($fn) {
$dir = "\"".$fn."\"";
$attr = trim(shell_exec("FOR %A IN (".$dir.") DO @ECHO %~aA"));
if($attr[3] === 'h')
return true;
return false;
}
?>
我看到您在问题中提到有一些方法可以排除以“.”开头的文件。和 linux 中的东西,但关于 windows 的信息很少。然后检查一下它不仅消除了以“。”开头的文件。 & '..' 但也标记出实际隐藏的文件,并且肯定会在 Windows 中工作。
关于php - Windows下php scandir()是否排除隐藏文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30290663/
你好, 我在名为 content 的目录中有以下文件:仅 index.php、page1.php、page2.php 和 page3.php。 然后我有这个代码: $column = scandir
我正在尝试使用 scandir() 和 foreach() 获取匹配的文件数组。 当我运行 scandir() 时,它会返回所有文件列表。这里没问题。 现在在第二步中,当我执行 foreach sca
TIA。凭借我的 PHP 补救技能,我无法弄清楚为什么 scandir 不能按字母顺序自动排序。 (将文件夹组合在一起并按字母顺序排序以及将文件组合在一起并按字母顺序排序也很好,但这并不重要。)我错过
我需要帮助,如何按文件日期对下面的代码进行排序? $dir2 = "flash/$plk/img"; $plks2 = scandir($dir2); $plkss2 = array_d
我正在使用 scandir 来匹配目录中的某些文件。 match 函数采用 const struct dirent *dp 参数。 但我还需要传递另一个参数。当我尝试这样做时,编译会发出警告(不是错误
所以我试图构建一个脚本来扫描目录并返回用作背景的随机图像。 php 看起来是这样的: $dir = "views/img/bg/"; $dh = opendir($dir); while (fals
我想知道,我的 Scandir() 函数适用于 php $_GET 变量,因此该变量返回文件夹,但我遇到了问题,因为我不确定如何在存在错误时回显错误目录问题。 这是我收到的错误: Warning: s
我需要帮助,如何按文件日期对下面的代码进行排序? $dir2 = "flash/$plk/img"; $plks2 = scandir($dir2); $plkss2 = array_d
我试图列出有关指定目录中文件的信息,但收到内存故障核心转储错误。列出目录方法: int listdir(char *path) { struct dirent **dirlist; int n; c
我正在尝试通过子字符串过滤 scandir。我的函数可以正常工作,但只能使用预先确定的字符串。 int nameFilter(const struct dirent *entry) { if
我如何使用 scandir,以便它只用文件夹填充我的 struct dirent ** 名单? 最佳答案 您可以通过提供过滤函数来过滤要列出的实体,如果要将文件包含在列表中,该函数应返回非零值。 不幸
在我的程序中,我显示了一个文件列表。现在我正在使用带有内置 alphasort 函数的 scandir,但是我想根据创建日期进行排序。我写了自己的比较函数,但无论我测试多少,它都不起作用。这些项目以看
我希望我的脚本递归地 scandir, $files = scandir('/dir'); foreach($files as $file){ if(is_dir($file)){ echo
我在使用 scandir() 时遇到问题。我试图在我的云中子域下的页面上的 snaps 目录中显示文件。 这是我使用的 PHP。 $files = scandir('./snaps'); print_
我必须创建一个函数,将所有子文件夹列出到一个文件夹中。我有一个无文件过滤器,但该函数使用 scandir() 进行列表。这使得应用程序非常慢。是否有 scandir() 的替代方案,即使是非 nati
进行了一些搜索,但似乎无法找到我正在寻找的确切答案。 我想使用“scandir($dir)”提取带有编号文件名的文件,但要让它们正确排序。例如,文件名是: 1-something.ext 2-some
$contentdirectory = '/dead-wave/dead-wave_content'; $contentlaunch = scandir($contentdirectory
在UNIX® System Threads Reference ,在“线程安全”标题下是一个“不保证在所有 UNIX 系统上都是线程安全的”函数列表。函数 scandir() 不在此列表中,而 rea
我正在尝试使 scandir(); 函数超出其书面限制,我需要的不仅仅是它目前支持的 alpha 排序。我需要对 scandir(); 结果进行排序,以按修改日期排序。 我尝试了一些我在这里找到的解决
我遇到了 php glob 的一个特性功能,想知道到底发生了什么。 '; echo 'paths[0] = ' . $paths[0] .''; echo 'scandir count = ' . c
我是一名优秀的程序员,十分优秀!