コード例 #1
0
ファイル: PageCommand.java プロジェクト: flesire/jnode.mirror
  /** JNode command entry point. */
  @Override
  public void execute() throws Exception {
    err = getError().getPrintWriter();
    Reader r = null;
    boolean opened = false;
    try {
      if (argFile.isSet()) {
        r = new FileReader(argFile.getValue());
        opened = true;
      } else if (getInput().isTTY()) {
        // We cannot do this.  We need to use the console as the
        // source of command characters for the Page command.
        debugln(str_no_pipe);
        exit(1);
      } else {
        r = getInput().getReader();
      }
      setup();
      lineStore = new LineStore(r);
      pager();

    } catch (IOException ex) {
      debugln(ex.getMessage());
      exit(1);
    } finally {
      if (r != null && opened) {
        try {
          r.close();
        } catch (IOException ex) {
          // ignore
        }
      }
      tearDown();
    }
  }
コード例 #2
0
ファイル: DerbyCommand.java プロジェクト: neoedmund/jnode
  public void execute() throws Exception {
    @SuppressWarnings("unused")
    File home_dir = ARG_HOME.getValue();
    String command = FLAG_START.isSet() ? "start" : FLAG_STOP.isSet() ? "stop" : "?";

    // FIXME ... this needs to be passed to the server somehow.
    @SuppressWarnings("unused")
    int port = ARG_PORT.isSet() ? ARG_PORT.getValue() : 1527;

    NetworkServerControlImpl server = new NetworkServerControlImpl();

    int server_command = server.parseArgs(new String[] {command});

    if (server_command == NetworkServerControlImpl.COMMAND_START) {
      PrintWriter printWriter = getOutput().getPrintWriter();
      server.setLogWriter(printWriter);
      server.start(printWriter);
    } else if (server_command == NetworkServerControlImpl.COMMAND_SHUTDOWN) {
      server.shutdown();
    }

    //    server.executeWork(server_command);

    //    NetworkServerControl.main(new String[]{command});
  }
コード例 #3
0
ファイル: RunCommand.java プロジェクト: neoedmund/jnode
  @Override
  public void execute() throws Exception {
    final PrintWriter err = getError().getPrintWriter();
    final File file = argFile.getValue();

    Shell shell = null;
    try {
      shell = ShellUtils.getShellManager().getCurrentShell();
    } catch (NameNotFoundException e) {
      e.printStackTrace(err);
      exit(2);
    }

    if (shell == null) {
      err.println(err_null);
      exit(2);
    }

    String[] args = argArgs.getValues();

    int rc = shell.runCommandFile(file, null, args);
    if (rc != 0) {
      exit(rc);
    }
  }
コード例 #4
0
 public void execute() throws Exception {
   final File file = ARG_EDIT.getValue();
   if (file.isDirectory()) {
     getError().getPrintWriter().println(file + " is a directory");
   } else {
     TextEditor.main(new String[] {file.toString(), "ro"});
   }
 }
コード例 #5
0
 public void execute() throws Exception {
   File file = argFile.getValue();
   PrintWriter out = getOutput().getPrintWriter();
   PrintWriter err = getError().getPrintWriter();
   if (!file.exists()) {
     File parentFile = file.getParentFile();
     if (parentFile != null && !parentFile.exists()) {
       // FIXME ... this is wrong.  Touch should not do this.
       if (!parentFile.mkdirs()) {
         err.println(err_parent_dir);
         exit(2);
       }
     }
     if (file.createNewFile()) {
       out.println(str_created);
     } else {
       err.println(err_file);
       exit(1);
     }
   } else {
     file.setLastModified(System.currentTimeMillis());
   }
 }
コード例 #6
0
ファイル: TarCommand.java プロジェクト: neoedmund/jnode
  // TODO Allow working directory to be changed
  public void execute() {
    super.execute("tar");
    if (!checkMode()) {
      fatal(err_options, 1);
    }

    if (Archive.isSet()) archive = Archive.getValue();
    if (Suffix.isSet()) suffix = Suffix.getValue();
    if (Exclude.isSet()) exclude = Exclude.getValue();
    if (ExcludeFile.isSet()) excludeFile = ExcludeFile.getValue();
    if (FileList.isSet()) fileList = FileList.getValue();

    backup = Backup.isSet();
    bzip = UseBzip.isSet();
    gzip = UseGzip.isSet();
    interact = Interact.isSet();
    verify = Verify.isSet();
    showTotals = ShowTotals.isSet();
    keepOld = KeepOld.isSet();
    keepNew = KeepNew.isSet();
    recurse = !NoRecurse.isSet();
    unlink = Unlink.isSet();

    try {
      if ((mode & TAR_REQ_ARCH) != 0 && archive == null) {
        fatal("Archive required for -Acdtru", 1);
      }

      if ((mode & TAR_DECOMPRESS) != 0 && archive != null) {
        if (checkCompressed(archive) == -1) {
          // happens when -j or -z were specified, but the archive is not
          // in the given format.
          if (bzip) {
            fatal("Archive is not compressed with bzip2.", 1);
          }
          if (gzip) {
            fatal("Archive is not compressed with gzip.", 1);
          }
          fatal("Internal Error: checkCompressed() returned -1", -1);
        }
      }

      if ((mode & TAR_COMPRESS) != 0) {
        if (bzip) {
          compress = USE_BZIP;
        } else if (gzip) {
          compress = USE_GZIP;
        } else {
          compress = decompress;
        }
      }

      if ((mode & TAR_VERIFY) != 0 && verify) {
        // backup original archive
      }

      if ((mode & TAR_CREATE) != 0 && compress == 0) {
        compress = checkSuffix(archive);
      }

      if ((mode & TAR_INSERT) != 0) {
        insert(processFiles(Paths.getValues(), recurse));
      }

      if ((mode & TAR_UPDATE) != 0) {
        update(processFiles(Paths.getValues(), recurse));
      }

      if ((mode & TAR_CONCAT) != 0) {
        concat(processArchives(Paths.getValues()));
      }

      if ((mode & TAR_DELETE) != 0) {
        // delete();
      }

      if ((mode & TAR_EXTRACT) != 0) {
        if (decompress == 0 && archive == null) {
          if (bzip) {
            decompress = USE_BZIP;
          } else if (gzip) {
            decompress = USE_GZIP;
          }
        }
        extract();
      }

      if ((mode & TAR_LIST) != 0) {
        list();
      }

      if ((mode & TAR_DIFF) != 0) {
        diff();
      }
    } catch (Exception e) {
      e.printStackTrace();
      fatal(err_exception_uncaught, 1);
    }
  }