问题标签 [readdir]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
215 浏览

readdir - ext3 文件系统中的文件顺序变化

我有一个程序,其输出取决于 readdir 如何返回文件顺序。有什么方法可以通过 ext3 模拟不同的文件返回顺序

0 投票
1 回答
1840 浏览

linux - How do I avoid this race condition with readdir/inotify?

Suppose I want to invoke some command on all files in a directory and set a watch to invoke that command on all files that get created in that directory. If I do:

then some files will potentially be missed. If I call inotify_add_watch() before the readdir(), files may be acted on twice (it would require a fair bit of infrastructure to prevent acting twice, and it seems that the edge cases would be difficult to handle). Is there a simple way to avoid having to record the names of all files worked on during the readdir loop and comparing those to the names returned in the inotify_event structure? I can minimize the amount of necessary comparisons with:

And usually the second readdir() loop will do nothing, but this feels like a bad hack.

0 投票
1 回答
2531 浏览

php - PHP递归文件文件夹扫描按修改日期排序

我正在使用这个脚本来查看所有子文件夹和子文件夹的文件

有人可以告诉我如何使用 filemtime 函数(或其他函数),以便我可以按修改日期对子文件夹和文件进行排序?

0 投票
1 回答
90 浏览

php - 我的 php 脚本有问题

我有一个 php 脚本,它按字母表排列文件夹,但由于某种原因它也得到一个空白目录。这是代码:

我知道其中一些是不相关的,但以防万一他们是..当我测试它时,它显示a.php,b.php .... .php

怎么了?

0 投票
1 回答
98 浏览

php - php中的全局和计数器

我有这个脚本,它将我的文件夹排列在一些标签中,并且只需要 4 个项目。这太棒了!但我需要它按字母顺序排列项目

我有这个脚本,我想将它合并或替换为

我该怎么做?全局函数对我来说是新的......

0 投票
6 回答
3694 浏览

php - php sftp 段错误

如果下一个代码给我段错误,我需要做什么?

$sftp 在哪里

连接工作良好。段错误是只有我使用 readdir 函数时。

0 投票
3 回答
22045 浏览

c - C:检查文件类型。使用 lstat() 和宏不起作用

我使用 opendir() 打开一个目录,然后使用 readdir() 和 lstat() 来获取该目录中每个文件的统计信息。在此联机帮助页之后,我编写了无法按预期工作的代码。它确实列出了当前目录中的所有文件,但无论文件是常规文件、符号链接还是目录,它都不会打印出来。

0 投票
1 回答
1970 浏览

c - 扫描目录并在c中修改文件

我正在尝试创建一个扫描 Windows PC 上的文件夹的函数,每次扫描时,都会在一个名为“Filter.txt”的文件中附加字符串“Test Script”。

现在的问题是2,第一个是扫描必须在目录c:\LOG或其子目录中执行,第二个是我不知道如何链接fopen目录和文件名。

0 投票
1 回答
78 浏览

c - 如何将当前目录中的所有文件从c中的线程添加到数组中?

这似乎在调试器中工作正常,但是当我运行它时,终端上没有显示任何内容。我将把 stage1 方法中的 printf 行替换为:

我将添加更多代码以确保我始终指向正确的位置,但这就是我现在正在使用的。我希望它打印文件,所以我知道它可以工作。

0 投票
2 回答
4140 浏览

php - php递归文件夹readdir vs查找性能

我遇到了几篇关于性能和 readdir 的文章,这里是 php 脚本:

这会正确地回显文件/文件夹。

现在我发现了这个:

它还可以找到所有文件夹和文件,然后我可以像第一个代码一样创建一个数组。

我认为这system('find');比那个快,readdir但我想知道这是否是一个好习惯?非常感谢你