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)+:: +process.chdir(directory)+::
Changes the current working directory of the process. Changes the current working directory of the process.
+process.umask(mask)+ :: +process.umask([mask])+ ::
Sets the process's file mode creation mask. Child processes inherit the mask Sets or read the process's file mode creation mask. Child processes inherit
from the parent process. the mask from the parent process.
- returns the old mask. - returns the old mask if +mask+ argument is given, otherwise returns
the current mask.
+process.kill(pid, signal="SIGTERM")+ :: +process.kill(pid, signal="SIGTERM")+ ::
Send a signal to a process. +pid+ is the process id and +signal+ is the 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){ static Handle<Value> Umask(const Arguments& args){
HandleScope scope; HandleScope scope;
unsigned int old;
if(args.Length() < 1 || !args[0]->IsInt32()) { if(args.Length() < 1) {
old = umask(0);
umask((mode_t)old);
}
else if(!args[0]->IsInt32()) {
return ThrowException(Exception::TypeError( return ThrowException(Exception::TypeError(
String::New("argument must be an integer."))); String::New("argument must be an integer.")));
} }
unsigned int mask = args[0]->Uint32Value(); else {
unsigned int old = umask((mode_t)mask); old = umask((mode_t)args[0]->Uint32Value());
}
return scope.Close(Uint32::New(old)); return scope.Close(Uint32::New(old));
} }

8
test/simple/test-umask.js

@ -3,4 +3,10 @@ process.mixin(require("../common"));
var mask = 0664; var mask = 0664;
var old = process.umask(mask); 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