Package org.jboss.fresh.vfs

Examples of org.jboss.fresh.vfs.VFS


      log.debug("done");
      return;
    }

    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);
      Iterator it = col.iterator();

      out.put("                            " + "\t<DIR>" + "\t..\n", 10000L);
      while (it.hasNext()) {
        FileInfo fd = (FileInfo) it.next();
View Full Code Here


//    System.out.println("##[CatExe] : getStdIn():" + getStdIn());

    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;

        do {
          read = vfs.read(shell.getUserCtx(), op);

          // if file has no content(is asset, etc.) null is returned by vfs.read()
          if (read == null)
            break;
View Full Code Here

      log.debug("done");
      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.");

        } else {
          if (canThrowEx()) {
            throw new RuntimeException(param + ": Path already exists!");
View Full Code Here

            while (it.hasNext()) {
                Map.Entry ent = (Map.Entry) it.next();
                String path = (String) ent.getKey();
                String jndi = (String) ent.getValue();

                VFS mvfs = (VFS) ctx.lookup(jndi);
                vfs.mount(path, mvfs);
            }
        }
    }
View Full Code Here

            log.debug("done");
            return;
        }

        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

      return;
    }


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

    // List paths = new LinkedList();
    boolean direct = false;


    if ((params.length != 2) && (params.length != 3)) {
      if (canThrowEx()) {
        throw new Exception("Usage: ln TARGET LINK [-d]");
      } else {
        out.println("Usage: ln TARGET LINK [-d]");
      }
    } else {
      FileName target = new FileName(params[0]);
      FileName link = new FileName(params[1]);

      if ((params.length > 2) && (params[2].equals(directParam)))
        direct = true;

      if (target.isRelative())
        target = pwd.absolutize(target);
      target = vfs.resolve(shell.getUserCtx(), target, direct);
      if (link.isRelative())
        link = pwd.absolutize(link);
//      link = vfs.resolve(shell.getUserCtx(), link, true);

      boolean targetXsts, linkXsts;
      targetXsts = vfs.exists(shell.getUserCtx(), target, true);
      linkXsts = vfs.exists(shell.getUserCtx(), link, true);

      if (targetXsts && !linkXsts) {
        FileInfo linkInfo = new FileInfo(link, FileInfo.TYPE_LINK);
        linkInfo.setTarget(target);
        vfs.createFile(shell.getUserCtx(), linkInfo);

      } else {
        if (!targetXsts) {
          if (canThrowEx()) {
            throw new Exception(target + ": Target must exist! Cannot create a dead link!");
View Full Code Here

      return;
    }

    PrintWriter2 out = new PrintWriter2(new BufferWriter(getStdOut()));

    VFS vfs = shell.getVFS();
    FileName pwd = new FileName(shell.getEnvProperty("PWD"));
    boolean create = true;

    List paths = new LinkedList();

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

      if (param.equals(CREATE))
        create = false;
      else {
        FileName path = new FileName(param);
        if (path.isRelative())
          path = pwd.absolutize(path);

//        path = vfs.resolve(shell.getUserCtx(), path, true);
        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();

        if (vfs.exists(shell.getUserCtx(), path, true)) {
          FileInfo info = vfs.getFileInfo(shell.getUserCtx(), path, true);
          info.setLastModified(new Date());
          vfs.updateFile(shell.getUserCtx(), info);
          out.println(path + ": Modified date set to now.");
        } else if (create) {
          FileInfo info = new FileInfo(path, FileInfo.TYPE_FILE);
          info.setMime("undefined");
          vfs.createFile(shell.getUserCtx(), info);
          out.println(path + ": File created.");
        } else {
          out.println(path + ": File does not exist.");
        }
      }
View Full Code Here

      log.debug("done");
      return;
    }

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

    if (params.length == 2) {
      FileName file = new FileName(params[0]);
      FileName next = new FileName(params[1]);

      if (file.isRelative())
        file = pwd.absolutize(file);
      if (next.isRelative())
        next = pwd.absolutize(next);

      if (vfs.exists(shell.getUserCtx(), file, true) && vfs.exists(shell.getUserCtx(), next, true)) {
        vfs.moveBefore(shell.getUserCtx(), file, next);
      }

    } else if (params.length == 1) {
      FileName file = new FileName(params[0]);
      if (file.isRelative())
        file = pwd.absolutize(file);
      if (vfs.exists(shell.getUserCtx(), file, true))
        vfs.moveBefore(shell.getUserCtx(), file, null);

    }

    out.close();
View Full Code Here

  private HashMap mounts = new LinkedHashMap();

  protected MountData findFS(FileName name) {

    while(name != null) {
      VFS vfs = (VFS) mounts.get(name.toString());
      if(vfs != null) return new MountData(name, vfs);

      if(name.size() > 0)
        name = name.getBase(name.size()-1);
      else
View Full Code Here

            InputStream ins = null;
            if(file != null) {
                ins = new FileInputStream(file);
            } else {
                VFS vfs = shell.getVFS();
                FileName pwd = new FileName(shell.getEnvProperty("PWD"));
                FileName path = new FileName(vfile);
                if (path.isRelative())
                    path = pwd.absolutize(path);

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

                ins = new VFSInputStream(new SecureVFS(vfs, shell.getUserCtx()), path.toString());
            }

            if (enc == null || enc.trim().length() == 0) {
View Full Code Here

TOP

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

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.