PhantomJS - exists 方法
exists 方法检查系统中是否存在给定的文件路径。如果存在,则返回 true,否则返回 false。
语法
其语法如下 −
var fs = require('fs'); fs.exists(filepath);
示例
以下示例显示了 exists() 方法的用法。
命令 − phantomjs exist.js C: est\
var fs = require('fs'); var system = require('system'); console.log(fs.exists(system.args[1])); phantom.exit();
上述程序生成以下输出。
True
phantomjs_file_system_module_methods.html