Package org.jboss.fresh.vfs

Examples of org.jboss.fresh.vfs.FileName


    }

    Shell sh = getShell();
    VFS vfs = sh.getVFS();
    OutBuffer out = getStdOut();
    FileName fname;
    if (params == null || params.length == 0) {
      fname = new FileName(sh.getEnvProperty("PWD"));
    } else {
      fname = new FileName(sh.getEnvProperty("PWD")).absolutize(params[0]);
    }

    if (vfs.exists(null, fname, false)) {
      out.put("\n Directory of " + fname + "\n\n", 10000L);
      Collection col = vfs.list(null, fname, false);
View Full Code Here


  Shell sh;

//EMPTY CONSTRUCTOR
  public FPExpand(Shell shell) throws ShellException {
    sh = shell;
    user_dir = new FileName(shell.getEnvProperty("PWD"));
  }
View Full Code Here

  }

//CONSTRUCTOR WITH USER DIRECTORY
  public FPExpand(Shell shell, String ud) {
    sh = shell;
    user_dir = new FileName(ud);
  }
View Full Code Here

  public void expand(String pattern) throws Exception {
    if (pattern.startsWith("/")) {
      pattern = convertPattern(pattern);
//log.debug("pattern je poceo sa / i posle convert je "+pattern);
      expandPattern(pattern, new FileName("/"));
    } else {
      pattern = convertPattern(pattern);
//log.debug("pattern je nema pocetak ili je poceo sa . i posle convert je "+pattern);
      expandPattern(pattern, null);
    }
View Full Code Here

    BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
    BufferObjectReader oin = new BufferObjectReader(getStdIn());

    VFS vfs = shell.getVFS();

    FileName pwd = new FileName(shell.getEnvProperty("PWD"));

    List paths = new LinkedList();

    for (int i = 0; i < params.length; i++) {
      String param = params[i];

      FileName path = new FileName(param);
      if (path.isRelative())
        path = pwd.absolutize(path);

      path = vfs.resolve(shell.getUserCtx(), path, false);
      paths.add(path);
    }


//    List result = new LinkedList();

//    if no paths given, read from stdin
    if (!paths.isEmpty()) {
      Iterator it = paths.iterator();
      while (it.hasNext()) {
        FileName path = (FileName) it.next();

        FileOpInfo op = new FileOpInfo();
        op.filename = path;
//        op.offset = 0;
        FileReadInfo read = null;
View Full Code Here

      return;
    }

    PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
    VFS vfs = shell.getVFS();
    FileName pwd = new FileName(shell.getEnvProperty("PWD"));

    // List paths = new LinkedList();

    for (int i = 0; i < params.length; i++) {
      String param = params[i];

      FileName path = new FileName(param);
      if (path.isRelative())
        path = pwd.absolutize(path);

//      path = vfs.resolve(shell.getUserCtx(), path, true);

      if (vfs.exists(shell.getUserCtx(), path.getPath(), true)) {

        if (!vfs.exists(shell.getUserCtx(), path, true)) {
          FileInfo dir = new FileInfo(path, FileInfo.TYPE_DIR);
          vfs.createFile(shell.getUserCtx(), dir);
          //out.println(param+ ": Directory successfully created.");
View Full Code Here

            // create new Cache Object implementation
            //shell.setCache(new SimpleMemCache());
            shell.setContext(new FlatContext());
            try {
                if (shell.getVFS().exists(null, new FileName("/etc/shell/init.rc"), true))
                    shell.executeAsObject("run /etc/shell/init.rc"); // NullInput In case no redirects specified of course
            } catch (Exception ex) {
                log.error("Error while executing 'run /etc/shell/init.rc'", ex);
                if (shellout != null)
                    shellout.put("init.rc returned an error: " + ex.toString() + " : " + (ex.getCause() == null ? "" : ex.getCause().toString()), 10000);
View Full Code Here

        FileInfo inf = null;
        try {
//log.debug("[ShellRuntime] Resolving filename to class");

            FileName cmdnm = new FileName(command);
            if (!cmdnm.isAbsolute()) {


                String path = getPATH();

                FileName pwdnm = new FileName(pwd);
                StringTokenizer t = new StringTokenizer(path, ":");
                while (t.hasMoreTokens()) {
                    try {
                        FileName dir = new FileName(t.nextToken());
                        if (!dir.isAbsolute()) {
                            dir = pwdnm.absolutize(dir);
                        }


                        FileName full = dir.absolutize(cmdnm);
//            log.debug("[ShellRuntime] trying: " + full);
                        inf = shell.getVFS().getFileInfo(shell.getUserCtx(), full, false);
                        if (inf != null) { // got it!
//            log.debug("[ShellRuntime] found file!");
                            break;
View Full Code Here

        }

        BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
        VFS vfs = shell.getVFS();

        FileName pwd = new FileName(shell.getEnvProperty("PWD"));

        String out = OUTPUT_STRING;
        boolean output = false;        // was out param already processed
        boolean longOut = false;
        boolean rslvLinks = true;
        // boolean help = false;

        List paths = new LinkedList();

        for (int i = 0; i < params.length; i++) {

            String param = params[i];

            if (!longOut && param.equals(OPTION_LONG))
                longOut = true;

            else if (!output && param.startsWith(OUTPUT)) {
                out = param.substring(OUTPUT.length());
                output = true;

            }
/*       else if (param.equals(HELP)) {
        help = true;
        oout.writeObject("Usage: ls [--help] [-ex] [-out=OUTPUT] [-l] [--help]\n");
        oout.writeObject("       OUTPUT = string | filename | fileinfo; String is default.\n");
        oout.writeObject("       -l = long output; Makes difference only with -out=string.\n");
        oout.writeObject("       --help = Prints this.\n");
        oout.close();
        System.out.println("[LsExe] : done.");
        return;

      }
*/
            else {
                FileName path = new FileName(param);
                if (path.isRelative())
                    path = pwd.absolutize(path);

//        path = vfs.resolve(shell.getUserCtx(), path, true);
                paths.add(path);
            }
        }

        // if no paths given, list working dir
        if (paths.isEmpty())
            paths.add(pwd);


        // now we have all paths resolved and absolute in FileName form in the 'paths' list
        //log.debug("Paths: " + paths);


        List expPaths = new LinkedList();
        Iterator it = paths.iterator();
        while (it.hasNext()) {
            FileName filename = (FileName) it.next();
            List children = vfs.list(shell.getUserCtx(), filename, !rslvLinks);
            //log.debug("Expanding children: " + children);
            expPaths.addAll(children);
        }
        paths = expPaths;
View Full Code Here

            InputStreamBuffer bin = new InputStreamBuffer(bain, false);
            bin.setProperties(env);
            in = bin;
           
          } else {
            FileName fname = new FileName(cmdl.getStdInRedir());
            if (fname.isRelative()) {
              fname = new FileName(getEnvProperty("PWD")).absolutize(fname);
            }
            InputStreamBuffer bin = new InputStreamBuffer(new VFSInputStream(new SecureVFS(vfs, uctx), fname.toString()), cmdl.isInObjMode());
            bin.setProperties(env);
            in = bin;
          }

        } catch (IOException ex) {
          throw new ShellException("Exception occured while initializing input buffer: " + ex.toString());
        }

      }


      if (in == null) {
//log.debug("No output redirect setup...");
        if (hasin) {
          if (!"SINGLE".equals(getEnvProperty("TMODE"))) {
            in = new BufferImpl();
          } else {
            in = new MemFileBufferImpl();
          }
          // here we set whatever is maxsize for inputbuffer for this executable - we have this set
          // as attribute on the file or something ...
          // FIXME
          List input = cmdl.getStdInput();
          if(input != null) {
            in.setMaxSize(input.size());
            try {
              ((Buffer)in).putBuffer(new LinkedList(input), 1000);
              in.close();
            } catch (IOException ex) {
              throw new ShellException("Exception occured while initializing input buffer: " + ex.toString());
            }
          }
          in.setMaxSize(inbufmax); // should be a variable

        } else {
          in = new NullBuffer();
        }
      }

    } else {
//log.debug("Piping in previous out...");
      Object o_in = ((Process) joblist.getLast()).getOutputBuffer();
      if (!(o_in instanceof InBuffer)) {
        throw new ShellException("Invalid pipe chain. Trying to read from write-only buffer.");
      }
      in = (InBuffer) o_in;
    }

//log.debug("\n\nin = " + in);

    OutBuffer out = null;

    if (cmdl.size() == joblist.size() + 1) {

      if (cmdl.getSLStdOutRedir() != null) {
        try {
          OutputStreamBuffer bout = new OutputStreamBuffer(new FileOutputStream(cmdl.getSLStdOutRedir(), cmdl.getSLAppend()), cmdl.isSLOutObjMode());
          bout.setProperties(env);
          out = bout;
          p.setRedirected(true);
        } catch (IOException ex) {
          throw new ShellException("Exception occured while initializing output buffer: " + ex.toString());
        }

      } else if (cmdl.getStdOutRedir() != null) {
        try {
          ////out=new OutputStreamBuffer(new VFSOutputStream(new SecureVFS(vfs, uctx), cmdl.getStdOutRedir(), cmdl.getAppend()), cmdl.isOutObjMode());

          //if(TxSupport.isActive()) throw new ShellException("Illegal state - inside transaction.");
          //TxSupport.begin();
          try {
            FileName fname = new FileName(cmdl.getStdOutRedir());
            if (fname.isRelative()) {
              fname = new FileName(getEnvProperty("PWD")).absolutize(fname);
            }
            OutputStreamBuffer bout = new OutputStreamBuffer(new LazyVFSOutputStream(new SecureVFS(vfs, uctx), fname.toString(), cmdl.getAppend()), cmdl.isOutObjMode());
            bout.setProperties(env);
            out = bout;
            p.setRedirected(true);
            //TxSupport.commit();
          } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of org.jboss.fresh.vfs.FileName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.