Browse Source

Updated patch of node.cc for supporting reading of umask

v0.7.4-release
Rasmus Andersson 15 years ago
committed by Ryan Dahl
parent
commit
374300ca8d
  1. 9
      doc/api.txt
  2. 14
      src/node.cc
  3. 8
      test/simple/test-umask.js

9
doc/api.txt

@ -143,10 +143,11 @@ Gets/sets the group identity of the process. (See setgid(2).)
+process.chdir(directory)+::
Changes the current working directory of the process.
+process.umask(mask)+ ::
Sets the process's file mode creation mask. Child processes inherit the mask
from the parent process.
- returns the old mask.
+process.umask([mask])+ ::
Sets or read the process's file mode creation mask. Child processes inherit
the mask from the parent process.
- returns the old mask if +mask+ argument is given, otherwise returns
the current mask.
+process.kill(pid, signal="SIGTERM")+ ::
Send a signal to a process. +pid+ is the process id and +signal+ is the

14
src/node.cc

@ -471,14 +471,18 @@ static Handle<Value> Cwd(const Arguments& args) {
static Handle<Value> Umask(const Arguments& args){
HandleScope scope;
if(args.Length() < 1 || !args[0]->IsInt32()) {
unsigned int old;
if(args.Length() < 1) {
old = umask(0);
umask((mode_t)old);
}
else if(!args[0]->IsInt32()) {
return ThrowException(Exception::TypeError(
String::New("argument must be an integer.")));
}
unsigned int mask = args[0]->Uint32Value();
unsigned int old = umask((mode_t)mask);
else {
old = umask((mode_t)args[0]->Uint32Value());
}
return scope.Close(Uint32::New(old));
}

8
test/simple/test-umask.js

@ -3,4 +3,10 @@ process.mixin(require("../common"));
var mask = 0664;
var old = process.umask(mask);
assert.equal(true, mask === process.umask(old));
assert.equal(mask, process.umask(old));
// confirm reading the umask does not modify it.
// 1. If the test fails, this call will succeed, but the mask will be set to 0
assert.equal(old, process.umask());
// 2. If the test fails, process.umask() will return 0
assert.equal(old, process.umask());

Loading…
Cancel
Save