PhantomJS - isLink 方法

如果给定的文件路径是符号链接,则此方法返回 true;否则返回 false

语法

其语法如下 −

var fs = require('fs');
fs.isLink(filepath);

示例

以下代码显示如何使用 isLink 方法。

命令 − phantomjs islink.js phantomjs\bin ouch

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

if(fs.isLink(path)) 
   console.log('"'+path+'" is a link.'); 
else 
   console.log('"'+path+'" is an absolute path'); 
phantom.exit(); 

上述程序生成以下输出

"phantomjs\bin	ouch" is an absolute path

phantomjs_file_system_module_methods.html