Browse Source

windows: fix test-umask

v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
acc120a37b
  1. 16
      src/node.cc
  2. 9
      test/simple/test-umask.js

16
src/node.cc

@ -1444,13 +1444,15 @@ static Handle<Value> Cwd(const Arguments& args) {
}
#ifdef __POSIX__
#ifndef __POSIX__
# define umask _umask
#endif
static Handle<Value> Umask(const Arguments& args){
static Handle<Value> Umask(const Arguments& args) {
HandleScope scope;
unsigned int old;
if(args.Length() < 1 || args[0]->IsUndefined()) {
if (args.Length() < 1 || args[0]->IsUndefined()) {
old = umask(0);
umask((mode_t)old);
@ -1484,6 +1486,8 @@ static Handle<Value> Umask(const Arguments& args){
}
#ifdef __POSIX__
static Handle<Value> GetUid(const Arguments& args) {
HandleScope scope;
assert(args.Length() == 0);
@ -1491,6 +1495,7 @@ static Handle<Value> GetUid(const Arguments& args) {
return scope.Close(Integer::New(uid));
}
static Handle<Value> GetGid(const Arguments& args) {
HandleScope scope;
assert(args.Length() == 0);
@ -1538,6 +1543,7 @@ static Handle<Value> SetGid(const Arguments& args) {
return Undefined();
}
static Handle<Value> SetUid(const Arguments& args) {
HandleScope scope;
@ -1577,6 +1583,7 @@ static Handle<Value> SetUid(const Arguments& args) {
return Undefined();
}
#endif // __POSIX__
@ -2187,6 +2194,8 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
NODE_SET_METHOD(process, "chdir", Chdir);
NODE_SET_METHOD(process, "cwd", Cwd);
NODE_SET_METHOD(process, "umask", Umask);
#ifdef __POSIX__
NODE_SET_METHOD(process, "getuid", GetUid);
NODE_SET_METHOD(process, "setuid", SetUid);
@ -2194,7 +2203,6 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
NODE_SET_METHOD(process, "setgid", SetGid);
NODE_SET_METHOD(process, "getgid", GetGid);
NODE_SET_METHOD(process, "umask", Umask);
NODE_SET_METHOD(process, "dlopen", DLOpen);
NODE_SET_METHOD(process, "_kill", Kill);
#endif // __POSIX__

9
test/simple/test-umask.js

@ -22,7 +22,14 @@
var common = require('../common');
var assert = require('assert');
var mask = '0664';
// Note in Windows one can only set the "user" bits.
var mask;
if (process.platform == 'win32') {
mask = '0600';
} else {
mask = '0664';
}
var old = process.umask(mask);
assert.equal(parseInt(mask, 8), process.umask(old));

Loading…
Cancel
Save