summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulien Gilli <julien.gilli@joyent.com>2015-01-12 18:36:08 -0800
committerJulien Gilli <julien.gilli@joyent.com>2015-01-12 18:36:08 -0800
commit21c2636c9a7ee3473addcee0a6cd608e8952be79 (patch)
tree403cb318d9904d576d4ae6b3397d2d79c8ce6899 /lib
parentc3155779945ee21cee4cc5abf318b89d51905156 (diff)
parent29449349da5ef7e23689396c21bae003d81e0081 (diff)
downloadnode-21c2636c9a7ee3473addcee0a6cd608e8952be79.tar.gz
Merge remote-tracking branch 'upstream/v0.12' into merge-0-10-into-0-12
Diffstat (limited to 'lib')
-rw-r--r--lib/fs.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 7731f244b..a5eb5351a 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -50,6 +50,10 @@ var O_RDWR = constants.O_RDWR || 0;
var O_SYNC = constants.O_SYNC || 0;
var O_TRUNC = constants.O_TRUNC || 0;
var O_WRONLY = constants.O_WRONLY || 0;
+var F_OK = constants.F_OK || 0;
+var R_OK = constants.R_OK || 0;
+var W_OK = constants.W_OK || 0;
+var X_OK = constants.X_OK || 0;
var isWindows = process.platform === 'win32';
@@ -182,6 +186,39 @@ fs.Stats.prototype.isSocket = function() {
return this._checkModeProperty(constants.S_IFSOCK);
};
+fs.F_OK = F_OK;
+fs.R_OK = R_OK;
+fs.W_OK = W_OK;
+fs.X_OK = X_OK;
+
+fs.access = function(path, mode, callback) {
+ if (!nullCheck(path, callback))
+ return;
+
+ if (typeof mode === 'function') {
+ callback = mode;
+ mode = F_OK;
+ } else if (typeof callback !== 'function') {
+ throw new TypeError('callback must be a function');
+ }
+
+ mode = mode | 0;
+ var req = new FSReqWrap();
+ req.oncomplete = makeCallback(callback);
+ binding.access(pathModule._makeLong(path), mode, req);
+};
+
+fs.accessSync = function(path, mode) {
+ nullCheck(path);
+
+ if (mode === undefined)
+ mode = F_OK;
+ else
+ mode = mode | 0;
+
+ binding.access(pathModule._makeLong(path), mode);
+};
+
fs.exists = function(path, callback) {
if (!nullCheck(path, cb)) return;
var req = new FSReqWrap();