joyent/node — pull request #3400 by jasonknight (2012-06-10 10:46:35+00:00)
Title: Modification to fs core module

Hi,

For some reason, fs.existsSync wasn't working for me, I didn't find the problem, maybe a misuse on my part, but when I looked at the code, I noticed that it was using a call to fs.stat, and returning true/false based on whether or not this threw an error because the path didn't exist.

Changing from stat to lstatSync made the function work again, but it seemed to me unecessarily expensive to base the function off of throwing an error so I added a simple exists method in c++ that returns true/false based on a call to open. The existing async call is left alone, as I only needed the sync version and was a bit unsure how to implement the async version, but I will look into that. I wrote a little test in the test directory to make sure it works, and have been using it locally so far.

If you'd like to pull it, or make some suggestions how I could better do it the Node way, i'd be happy to refactor it.

Cheers,
/Jason Knight