PhantomJS 文件系统 list 方法用法


发布日期 : 2020-12-25 22:30:57 UTC

访问量: 10 次浏览

PhantomJS list列表

list 方法返回目录中所有存在的文件。

语法

list 语法如下:

var fs = require('fs');
fs.list(path);

示例

以下示例显示了使用 list 方法的示例。

命令-phantomjs list.js C:\phantomjs\

var fs = require('fs');
var system = require('system');
var path = system.args[1];

if (fs.isDirectory(path)) {
console.log(fs.list(path));
}
phantom.exit();

以上程序生成以下输出

.,..,bin,ChangeLog,examples,LICENSE.BSD,README.md,third-party.txt

输出显示了PhantomJS目录中的所有文件。