-
• #2
You can't at the moment - the best you could do is
require("fs").readdir().indexOf("foo")>=0
Perhaps it should return
undefined
rather than an empty string if the file doesn't exist? -
• #3
I would prefer to get a 'undefined' instead of an empty string. This way its easier and cleaner to decide if the operation was successful and what actions to take. e.g. send 200 vs. 404.
-
• #4
fs.readFileSync in v1.51 now returns undefined if the file is not found. Thanks a lot Gordon.
How can i catch an fs.readFileSync error if a requested file is not available on sd-card? Right now i get the same result for an empty file and if the file is not available.