Package org.jboss.fresh.vfs

Examples of org.jboss.fresh.vfs.FileName



  public void update(FileInfo fi) throws Exception {
    // look up info for CompositeName
    // apply new info to it
    FileName adjusted = root.absolutize(fi.getFileName().toString());
    File thefile = new File(fsroot, adjusted.toString());

    tags.put(thefile, fi.getTag());
  }
View Full Code Here


  }


  // ko klices getInt na result setu, pa da je ta int nastavljen na NULL, dobis nazaj 0! Zato ne sme biti noben index 0!
  public void remove(FileName name) throws Exception {
    FileName adjusted = root.absolutize(name.toString());
    File thefile = new File(fsroot, adjusted.toString());

   
    if(!thefile.exists())
      throw new VFSException("File does not exist: " + name);
   
View Full Code Here

  }


  public void rename(FileName oldPath, FileName newPath) throws Exception {
    FileName adjusted = root.absolutize(oldPath.toString());
    File thefile = new File(fsroot, adjusted.toString());

    if(!thefile.exists())
      throw new VFSException("File does not exist: " + oldPath);

    FileName adjNu = root.absolutize(newPath.toString());
    File newFile = new File(fsroot, adjNu.toString());

    thefile.renameTo(newFile);
  }
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) {
                reader = new BufferedReader(new InputStreamReader(ins));
            } else {
View Full Code Here

    }

    Shell sh = getShell();
    VFS vfs = sh.getVFS();
    String to = params[0];
    FileName fname = new FileName(to);
    if (fname.isRelative())
      fname = new FileName(sh.getEnvProperty("PWD")).absolutize(fname);

//    System.out.println("****");
//    System.out.println("****  fname: " + fname);
//    System.out.println("****");
//    if(vfs.exists(null, fname, false)) {
//      sh._setPWD(fname.toString());
//    }


    FileInfo info = vfs.getFileInfo(null, fname, false);
    if (info == null || !info.isDirectory()) {
      if (canThrowEx()) {
        throw new RuntimeException("Can't find the path specified: " + fname + "\n\n");
      } else {
        out.put("Can't find the path specified: " + fname + "\n\n", 10000L);
      }
    } else {
      sh._setPWD(fname.toString());
    }

    log.debug("done");
  }
View Full Code Here

    }

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

    FileName pwd = new FileName(shell.getEnvProperty("PWD"));
    String out = OUTPUT_STRING;
    FileName target = null;
    Collection result = new HashSet();


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

        if (param.startsWith(OUTPUT))
          out = param.substring(OUTPUT.length());

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

          target = path;
        }
      }
View Full Code Here

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

    VFS vfs = shell.getVFS();
    FileName pwd = new FileName(shell.getEnvProperty("PWD"));
    FileName path = null;
    boolean add = false;
    HashMap attrs = new HashMap();

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

      if ((i == 0) && param.equals(ADD))
        add = true;

      else if (add && (i == 1) || (i == 0)) {
        FileName filepath = new FileName(param);
        if (filepath.isRelative())
          filepath = pwd.absolutize(filepath);

//        filepath = vfs.resolve(shell.getUserCtx(), filepath, true);
        if (vfs.exists(shell.getUserCtx(), filepath, true)) {
          path = filepath;
View Full Code Here

    }

    BufferObjectWriter oout = new BufferObjectWriter(getStdOut());

    Shell sh = getShell();
    FileName fname = new FileName(params[0]);
    if (!fname.isAbsolute()) {
      fname = new FileName(sh.getEnvProperty("PWD")).absolutize(fname);
    }
    log.debug("fname: " + fname);

    FileInfo inf = sh.getVFS().getFileInfo(sh.getUserCtx(), fname, true);

    log.debug("info: " + inf);
    for (int i = 1; i < params.length - 1; i++) {

      String val = params[i];
      log.debug("val: " + val);
//      if(val.equals("createDate")) {
//        inf.setCreateDate(params[++i]);
//      } else if(val.equals("lastModified")) {
//        inf.setLastModified(params[++i]);
//      } else if(val.equals("isComplete")) {
      if (val.equals("isComplete")) {
        inf.setComplete(params[++i].startsWith("t") || params[i].startsWith("T") || params[i].startsWith("1"));
      } else if (val.equals("mime")) {
        inf.setMime(params[++i]);
      } else if (val.equals("linkto")) {
        FileName fn = new FileName(params[++i]);
        if (fn.isRelative()) {
          fn = new FileName(sh.getEnvProperty("PWD")).absolutize(fn);
        }

        if (!sh.getVFS().exists(sh.getUserCtx(), fn, true)) {
          if (canThrowEx()) {
            throw new RuntimeException("The specfied linkto file does not exist:" + fn);
View Full Code Here

    }

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

      LinkedList paths = new LinkedList();
      boolean force = false;
      boolean errors = false;

      for (int i = 0; i < params.length; i++) {
        String param = params[i];
        log.debug("param:" + param);
        if ((i == 0) && param.equals(FORCE))
          force = true;
        else {
          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, true) && i != params.length - 1) {
            if (canThrowEx()) {
              throw new RuntimeException(param + ": Path already exists!");
            } else {
              out.println(param + ": Path does not exists!");
              errors = true;
            }
            break;
          } else
            paths.add(path);
        }
      }

      if ((paths.size() <= 1) || (errors && !force)) {
        out.println("Usage: mv FILES DEST_DIR");
        out.println("       mv FILE DEST_FILE");

      } else {
        FileName lastPath = (FileName) paths.removeLast();
        boolean lastPathXsists = vfs.exists(shell.getUserCtx(), lastPath, true);

        if (lastPathXsists) {
          FileInfo lastInfo = vfs.getFileInfo(shell.getUserCtx(), lastPath, false);

          if (lastInfo.isDirectory() && (force || !errors)) {
            log.debug("1.Moving multiple files to dir.");
            Iterator it = paths.iterator();
            while (it.hasNext()) {
              FileName path = (FileName) it.next();
              FileInfo info = vfs.getFileInfo(shell.getUserCtx(), path, true);
              if (move(info, lastPath.absolutize(path.getName()), force, vfs, out) && !force)
                return;
            }
          } else if ((paths.size() == 1) && force) {
            log.debug("1.Moving file (overwrite).");
            FileName path = (FileName) paths.getFirst();
            FileInfo info = vfs.getFileInfo(shell.getUserCtx(), path, true);
            if (move(info, lastPath, force, vfs, out) && !force)
              return;

          } else {
            if (canThrowEx()) {
              throw new RuntimeException(lastPath + ": Destination path is not a directory!");
            } else {
              out.println(lastPath + ": Destination path is not a directory!");
            }
          }

        } else if (paths.size() == 1) {
          log.debug("1.Moving file.");
          FileName path = (FileName) paths.getFirst();
          FileInfo info = vfs.getFileInfo(shell.getUserCtx(), path, true);
          if (move(info, lastPath, force, vfs, out) && !force)
            return;

        } else {
View Full Code Here

      return;
    }

    PrintWriter2 out = new PrintWriter2(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);

      log.debug("FREAKING PATH = " + path);
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.