Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: src/d8-posix.cc

Issue 1602023: Add os.unsetenv to d8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 if (*value == NULL) { 656 if (*value == NULL) {
657 const char* message = 657 const char* message =
658 "os.setenv(): String conversion of variable contents failed."; 658 "os.setenv(): String conversion of variable contents failed.";
659 return ThrowException(String::New(message)); 659 return ThrowException(String::New(message));
660 } 660 }
661 setenv(*var, *value, 1); 661 setenv(*var, *value, 1);
662 return v8::Undefined(); 662 return v8::Undefined();
663 } 663 }
664 664
665 665
666 Handle<Value> Shell::UnsetEnvironment(const Arguments& args) {
667 if (args.Length() != 1) {
668 const char* message = "unsetenv() takes one argument";
669 return ThrowException(String::New(message));
670 }
671 String::Utf8Value var(args[0]);
672 if (*var == NULL) {
673 const char* message =
674 "os.setenv(): String conversion of variable name failed.";
675 return ThrowException(String::New(message));
676 }
677 unsetenv(*var);
678 return v8::Undefined();
679 }
680
681
666 void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) { 682 void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) {
667 os_templ->Set(String::New("system"), FunctionTemplate::New(System)); 683 os_templ->Set(String::New("system"), FunctionTemplate::New(System));
668 os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory)); 684 os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory));
669 os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment)); 685 os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment));
686 os_templ->Set(String::New("unsetenv"), FunctionTemplate::New(UnsetEnvironment) );
Søren Thygesen Gjesse 2010/04/13 07:31:45 Long line.
670 os_templ->Set(String::New("umask"), FunctionTemplate::New(SetUMask)); 687 os_templ->Set(String::New("umask"), FunctionTemplate::New(SetUMask));
671 os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory)); 688 os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory));
672 os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory)); 689 os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory));
673 } 690 }
674 691
675 } // namespace v8 692 } // namespace v8
OLDNEW
« no previous file with comments | « src/d8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698