Add os.unsetenv to d8.

Review URL: http://codereview.chromium.org/1602023

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4393 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2010-04-13 08:44:50 +00:00
parent 0c4bac296b
commit 7914312403
2 changed files with 19 additions and 0 deletions

View File

@ -663,10 +663,28 @@ Handle<Value> Shell::SetEnvironment(const Arguments& args) {
}
Handle<Value> Shell::UnsetEnvironment(const Arguments& args) {
if (args.Length() != 1) {
const char* message = "unsetenv() takes one argument";
return ThrowException(String::New(message));
}
String::Utf8Value var(args[0]);
if (*var == NULL) {
const char* message =
"os.setenv(): String conversion of variable name failed.";
return ThrowException(String::New(message));
}
unsetenv(*var);
return v8::Undefined();
}
void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) {
os_templ->Set(String::New("system"), FunctionTemplate::New(System));
os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory));
os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment));
os_templ->Set(String::New("unsetenv"),
FunctionTemplate::New(UnsetEnvironment));
os_templ->Set(String::New("umask"), FunctionTemplate::New(SetUMask));
os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory));
os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory));

View File

@ -175,6 +175,7 @@ class Shell: public i::AllStatic {
static Handle<Value> System(const Arguments& args);
static Handle<Value> ChangeDirectory(const Arguments& args);
static Handle<Value> SetEnvironment(const Arguments& args);
static Handle<Value> UnsetEnvironment(const Arguments& args);
static Handle<Value> SetUMask(const Arguments& args);
static Handle<Value> MakeDirectory(const Arguments& args);
static Handle<Value> RemoveDirectory(const Arguments& args);