Phantomjs-list-method

提供:Dev Guides
移動先:案内検索

PhantomJS-リスト

*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();

上記のプログラムは、次の output を生成します。

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

出力には、PhantomJSディレクトリにあるすべてのファイルが表示されます。