How can I synchronously check, using node.js, if a file or directory exists?
The documents on fs.stat() says to use fs.access() if you are not going to manipulate the file. It did not give a justification, might be faster or less memeory use?
I use node for linear automation, so I thought I share the function I use to test for file existence.
var fs = require("fs");
function exists(path){
//Remember file access time will slow your program.
try{
fs.accessSync(path);
} catch (err){
return false;
}
return true;
}