Commit 79143124 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

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
parent 0c4bac29
...@@ -663,10 +663,28 @@ Handle<Value> Shell::SetEnvironment(const Arguments& args) { ...@@ -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) { void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) {
os_templ->Set(String::New("system"), FunctionTemplate::New(System)); os_templ->Set(String::New("system"), FunctionTemplate::New(System));
os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory)); os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory));
os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment)); 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("umask"), FunctionTemplate::New(SetUMask));
os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory)); os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory));
os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory)); os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory));
......
...@@ -175,6 +175,7 @@ class Shell: public i::AllStatic { ...@@ -175,6 +175,7 @@ class Shell: public i::AllStatic {
static Handle<Value> System(const Arguments& args); static Handle<Value> System(const Arguments& args);
static Handle<Value> ChangeDirectory(const Arguments& args); static Handle<Value> ChangeDirectory(const Arguments& args);
static Handle<Value> SetEnvironment(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> SetUMask(const Arguments& args);
static Handle<Value> MakeDirectory(const Arguments& args); static Handle<Value> MakeDirectory(const Arguments& args);
static Handle<Value> RemoveDirectory(const Arguments& args); static Handle<Value> RemoveDirectory(const Arguments& args);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment