Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 |
| OLD | NEW |