Lines Matching defs:args
213 static bool GetTimeouts(const v8::FunctionCallbackInfo<v8::Value>& args,
215 if (args.Length() > 3) {
216 if (args[3]->IsNumber()) {
217 *total_timeout = args[3]
218 ->Int32Value(args.GetIsolate()->GetCurrentContext())
221 args.GetIsolate()->ThrowError("system: Argument 4 must be a number");
225 if (args.Length() > 2) {
226 if (args[2]->IsNumber()) {
227 *read_timeout = args[2]
228 ->Int32Value(args.GetIsolate()->GetCurrentContext())
231 args.GetIsolate()->ThrowError("system: Argument 3 must be a number");
414 void Shell::System(const v8::FunctionCallbackInfo<v8::Value>& args) {
415 HandleScope scope(args.GetIsolate());
418 if (!GetTimeouts(args, &read_timeout, &total_timeout)) return;
420 if (args.Length() > 1) {
421 if (!args[1]->IsArray()) {
422 args.GetIsolate()->ThrowError("system: Argument 2 must be an array");
425 command_args = args[1].As<Array>();
427 command_args = Array::New(args.GetIsolate(), 0);
430 args.GetIsolate()->ThrowError("Too many arguments to system()");
433 if (args.Length() < 1) {
434 args.GetIsolate()->ThrowError("Too few arguments to system()");
442 if (!exec_args.Init(args.GetIsolate(), args[0], command_args)) {
449 args.GetIsolate()->ThrowError("pipe syscall failed.");
453 args.GetIsolate()->ThrowError("pipe syscall failed.");
470 Isolate* isolate = args.GetIsolate();
477 args.GetReturnValue().Set(accumulator);
486 args.GetReturnValue().Set(accumulator);
489 void Shell::ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
490 if (args.Length() != 1) {
491 args.GetIsolate()->ThrowError("chdir() takes one argument");
494 String::Utf8Value directory(args.GetIsolate(), args[0]);
496 args.GetIsolate()->ThrowError(
501 args.GetIsolate()->ThrowError(v8_strerror(args.GetIsolate(), errno));
506 void Shell::SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args) {
507 if (args.Length() != 1) {
508 args.GetIsolate()->ThrowError("umask() takes one argument");
511 if (args[0]->IsNumber()) {
513 args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust());
514 args.GetReturnValue().Set(previous);
517 args.GetIsolate()->ThrowError("umask() argument must be numeric");
563 void Shell::MakeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
565 if (args.Length() == 2) {
566 if (args[1]->IsNumber()) {
567 mask = args[1]
568 ->Int32Value(args.GetIsolate()->GetCurrentContext())
571 args.GetIsolate()->ThrowError("mkdirp() second argument must be numeric");
574 } else if (args.Length() != 1) {
575 args.GetIsolate()->ThrowError("mkdirp() takes one or two arguments");
578 String::Utf8Value directory(args.GetIsolate(), args[0]);
580 args.GetIsolate()->ThrowError(
584 mkdirp(args.GetIsolate(), *directory, mask);
587 void Shell::RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
588 if (args.Length() != 1) {
589 args.GetIsolate()->ThrowError("rmdir() takes one or two arguments");
592 String::Utf8Value directory(args.GetIsolate(), args[0]);
594 args.GetIsolate()->ThrowError(
601 void Shell::SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
602 if (args.Length() != 2) {
603 args.GetIsolate()->ThrowError("setenv() takes two arguments");
606 String::Utf8Value var(args.GetIsolate(), args[0]);
607 String::Utf8Value value(args.GetIsolate(), args[1]);
609 args.GetIsolate()->ThrowError(
614 args.GetIsolate()->ThrowError(
621 void Shell::UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
622 if (args.Length() != 1) {
623 args.GetIsolate()->ThrowError("unsetenv() takes one argument");
626 String::Utf8Value var(args.GetIsolate(), args[0]);
628 args.GetIsolate()->ThrowError(