PhantomJS - readLink



This method returns the absolute path of a file or folder pointed by a symlink (or shortcut on Windows). If the path is not a symlink or shortcut, it will return an empty string.

Syntax

Its syntax is as follows −

fs.readLink(path);

Example

The following example shows how the readLink method works.

var fs = require('fs'); 
var path = 'C:\phantomjs\bin\readlink.txt';  

if (fs.isLink(path)) { 
   var absolute = fs.readLink(path); 
   console.log('The absolute path of "'+path+'" is "'+absolute+'"'); 
}
else 
   console.log('"'+path+'" is an absolute path');  
phantom.exit(); 

The above program generates the following output.

readlink.txt
phantomjs_file_system_module_methods.htm
Advertisements