Package org.jboss.fresh.vfs

Examples of org.jboss.fresh.vfs.FileInfo


      if (out.equals(OUTPUT_STRING)) {
        result = new LinkedList();

        while (it.hasNext()) {
          FileInfo info = (FileInfo) it.next();
          result.add(info.getFileName().toString() + "\n");
        }

      } else if (out.equals(OUTPUT_FILEINFO))
        result = links;

      else if (out.equals(OUTPUT_FILENAME)) {
        while (it.hasNext()) {
          FileInfo info = (FileInfo) it.next();
          result.add(info.getFileName());
        }
      }

      it = result.iterator();
      while (it.hasNext()) {
View Full Code Here


    if (path == null) {
      out.println("Usage: setattr [-ex] [-a] FILE NAME VALUE {NAME VALUE}");
      out.println("       -a = add attributes insted of set");

    } else {
      FileInfo info = vfs.getFileInfo(shell.getUserCtx(), path, true);
      if (add) {
        HashMap oldAttrs = info.getAttributes();
        oldAttrs.putAll(attrs);
      } else
        info.setAttributes(attrs);

      vfs.updateFile(shell.getUserCtx(), info);
    }

    out.close();
View Full Code Here

    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);
          } else {
            getStdOut().put(" The specified linkto file does not exist: " + fn, 10000L);
          }
          log.debug("done");
          return;
        }

        inf.setTarget(fn);
      } else {
        usage(out);
        return;
      }
    }
View Full Code Here

      } 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 {
          if (canThrowEx()) {
View Full Code Here

    } else {
      Iterator it = paths.iterator();
      while (it.hasNext()) {
        FileName file = (FileName) it.next();

        FileInfo info = vfs.getFileInfo(shell.getUserCtx(), file, direct);
        log.debug("Got info: " + info);

        out.println(info);
      }
    }
View Full Code Here

      } 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.Copying 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 (copy(info, lastPath.absolutize(path.getName()), force, vfs, out) && !force) {
                log.debug("done");
                return;
              }
            }

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

          } else
            out.println(lastPath + ": Destination path is not a directory!");

        } else if (paths.size() == 1) {
          log.debug("1.Copying file");
          FileName path = (FileName) paths.getFirst();
          FileInfo info = vfs.getFileInfo(shell.getUserCtx(), path, true);
          if (copy(info, lastPath, force, vfs, out) && !force) {
            log.debug("done");
            return;
          }
View Full Code Here

    log.debug("done.");
  }

  // returns true if errors occured
  private boolean copy(FileInfo sourceInfo, FileName dest, boolean force, VFS vfs, PrintWriter out) throws Exception {
    FileInfo copy = sourceInfo;
    FileName file = sourceInfo.getFileName();
    log.debug("SOURCE = " + file);
    log.debug("DEST   = " + dest);

    if (dest.isParent(file)) {
      out.println(file + ": Contains destination path! Operation canceled");
      if (!force)
        return true;

    } else if (copy.isDirectory()) {
      log.debug("2.Copying dir.");
      boolean destXsists = vfs.exists(shell.getUserCtx(), dest, true);

      if (force && destXsists)
        vfs.remove(shell.getUserCtx(), dest, true); // children stay intact

      else if (destXsists) {
        out.println(dest + ": Destination path already exsists! Use -f to override.");
        if (!force)
          return true;
      }

      copy.setFileName(dest);
      vfs.createFile(shell.getUserCtx(), copy);
      out.println(file + ": Path copied to " + dest);

      List fileInfos = vfs.list(shell.getUserCtx(), file, true);
      Iterator it = fileInfos.iterator();

      while (it.hasNext()) {
        FileInfo srcInfo = (FileInfo) it.next();
        boolean errors;
        errors = copy(srcInfo, dest.absolutize(srcInfo.getFileName().getName()), force, vfs, out);
        if (errors && !force)
          return true;
      }

View Full Code Here

TOP

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

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.