testing out the validateAndMask() function, with console.log's...
This commit is contained in:
parent
fd3de6be2c
commit
add00ce563
|
@ -3278,12 +3278,14 @@
|
|||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -3298,17 +3300,20 @@
|
|||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
@ -3425,7 +3430,8 @@
|
|||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
@ -3437,6 +3443,7 @@
|
|||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
@ -3451,6 +3458,7 @@
|
|||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -3458,12 +3466,14 @@
|
|||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
|
@ -3482,6 +3492,7 @@
|
|||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
|
@ -3562,7 +3573,8 @@
|
|||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
@ -3574,6 +3586,7 @@
|
|||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
@ -3695,6 +3708,7 @@
|
|||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
|
|
@ -1623,8 +1623,16 @@ function open(fs, context, path, flags, mode, callback) {
|
|||
* callback = makeCallback(callback);
|
||||
* }
|
||||
*/
|
||||
|
||||
callback = arguments[arguments.length - 1];
|
||||
if (arguments.length == 5){
|
||||
callback = arguments[arguments.length - 1];
|
||||
}
|
||||
else {
|
||||
//need to test this validateAndMakeMode
|
||||
console.log("open'd mode: " + mode)
|
||||
mode = validateAndMaskMode(mode, FULL_READ_WRITE_EXEC_PERMISSIONS, callback);
|
||||
console.log("mask'd mode: " + mode)
|
||||
}
|
||||
|
||||
if(!pathCheck(path, callback)) return;
|
||||
|
||||
function check_result(error, fileNode) {
|
||||
|
@ -1913,12 +1921,15 @@ function isUint32(value) {
|
|||
// Validator for mode_t (the S_* constants). Valid numbers or octal strings
|
||||
// will be masked with 0o777 to be consistent with the behavior in POSIX APIs.
|
||||
function validateAndMaskMode(value, def, callback) {
|
||||
console.log("Passed in mode: " + value)
|
||||
if(typeof def === 'function') {
|
||||
callback = def;
|
||||
def = undefined;
|
||||
}
|
||||
|
||||
if (isUint32(value)) {
|
||||
let newMode = value & FULL_READ_WRITE_EXEC_PERMISSIONS;
|
||||
console.log("Masked mode: " + newMode)
|
||||
return value & FULL_READ_WRITE_EXEC_PERMISSIONS;
|
||||
}
|
||||
|
||||
|
@ -1939,6 +1950,7 @@ function validateAndMaskMode(value, def, callback) {
|
|||
return false;
|
||||
}
|
||||
var parsed = parseInt(value, 8);
|
||||
console.log("Parsed + Masekd mode: " + parsed & FULL_READ_WRITE_EXEC_PERMISSIONS)
|
||||
return parsed & FULL_READ_WRITE_EXEC_PERMISSIONS;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,22 @@ describe('fs.open', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should create a new file when flagged for write, and set the mode', function(done) {
|
||||
var fs = util.fs();
|
||||
|
||||
fs.open('/myfile', 'w', 644, function(error) {
|
||||
if(error) throw error;
|
||||
|
||||
fs.stat('/myfile', function(error, result) {
|
||||
expect(error).not.to.exist;
|
||||
expect(result).to.exist;
|
||||
expect(result.type).to.equal('FILE');
|
||||
expect(result.mode).to.exist;
|
||||
expect(result.mode).to.equal(33188)
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
/**
|
||||
* This test is currently correct per our code, but incorrect according to the spec.
|
||||
* When we fix https://github.com/filerjs/filer/issues/314 we'll have to update this.
|
||||
|
|
Loading…
Reference in New Issue