PhantomJS - isExecutable 方法

此方法检查给定文件是否可执行。如果可执行,则返回 true;否则,返回 false。

语法

其语法如下 −

var fs=require('fs');
fs.isExecutable(filename);

示例

以下示例显示了 isExecutable 方法的用法。

命令 − Phantomjs isexecutable.js touch.js

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

if (fs.isExecutable(path)) { 
   console.log(path+" is executable."); 
} else {  
   console.log(path+" is NOT executable."); 
} 
phantom.exit(); 

上述程序生成以下输出

touch.js is NOT executable.

phantomjs_file_system_module_methods.html