Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Modification to fs core module #3400

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ email.md
blog.html
deps/v8-*
node_modules
*~
23 changes: 13 additions & 10 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,22 @@ fs.Stats.prototype.isSocket = function() {
};

fs.exists = function(path, callback) {
binding.stat(path, function(err, stats) {
binding.stat(path, function(err, stats) {
if (callback) callback(err ? false : true);
});
};
};
fs.existsSync = function (path) {
return binding.exists(path)
}

fs.existsSync = function(path) {
try {
binding.stat(path);
return true;
} catch (e) {
return false;
}
};
// fs.existsSync = function(path) {
// try {
// binding.stat(path);
// return true;
// } catch (e) {
// return false;
// }
// };

fs.readFile = function(path, encoding_) {
var encoding = typeof(encoding_) === 'string' ? encoding_ : null;
Expand Down
Loading