Package org.jboss.fresh.vfs

Examples of org.jboss.fresh.vfs.FileName


    }


    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);
View Full Code Here


    }

    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);
View Full Code Here

      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);

    }
View Full Code Here

    public VFSInputStream(SecureVFS vfs, String filename) throws IOException {
        this.vfs = vfs;
        opinf = new FileOpInfo();

        // check if file exists - if exists we get the resolved name
        FileInfo info = vfs.getFileInfo(new FileName(filename), false);
        if (info == null) throw new IOException("The specified file does not exist: " + filename);

        String device = (String) info.getAttributes().get("file-handler");
        if(device != null) {
          try {
View Full Code Here

    }
  }

  public void onCreate(FileInfo fi) {
    // System.out.println( "[VFSCacheWrapper] [onCreate()] " +fi.getFileName() );
    FileName pe = fi.getFileName();
    VFSCacheItem item = new VFSCacheItem();
    cache.put(pe, item);

    item.setFileInfo(fi);
    item.setExists(new Boolean(true));
View Full Code Here

    item.setContent(new Boolean(false));
  }

  public void onUpdate(FileInfo fi) {
    // System.out.println( "[VFSCacheWrapper] [onUpdate()] " + fi.getFileName() );
    FileName pe = fi.getFileName();
    VFSCacheItem item = getCachedItem(pe);

    item.setFileInfo(fi);
    item.setExists(new Boolean(true));
  }
View Full Code Here

    // log.trace("/vfs/cache", "[resolve()] File " + pe + ", faster = " + faster);
    List res = new ArrayList();
    List[] result = new List[]{res};
    res.add(pe);
    Iterator it = pe.iterateTokens();
    FileName path = new FileName(new Vector(), true);

    int i = 0;
    while (it.hasNext()) {
      i++;
      Object token = it.next();
      path = path.absolutize((String) token);
      // System.out.println( "[VFSCacheWrapper] [resolve()] Step = " +path );
      // log.trace("/vfs/cache", "Step =  " + path);
      // System.out.println( "[VFSCacheWrapper] [resolve()] tokens = " +path );
      // log.trace("/vfs/cache", "tokens = " + path);

      FileInfo[] fromCache = getFileInfo(path);
      FileInfo fi;

      // if not cached
      // and not cached as inexisting
      if (fromCache != null && fromCache[0] != null)
        fi = fromCache[0];

      else {
        // ce pa imamo slucajno cachirano, da ne obstaja potem je resolve success!
        boolean[] existsFromCache = exists(path);
        if (existsFromCache != null && existsFromCache[0] == false) {
          res.add(path);
          break;
        }

        result = null;
        break;
      }

      if (fi.isLink()) {
        path = fi.getTarget();
        if (!faster) {
          FileName tmp = path;
          for (int j = i; j < pe.getTokens().size(); j++)
            tmp.absolutize((String) pe.getTokens().get(j));
          res.add(tmp);
        }
      }
    }
View Full Code Here

  /* (non-Javadoc)
   * @see org.jboss.fresh.vfs.RootVFS#mount(java.lang.String, java.lang.String)
   */
  public void mount(String path, VFS vfs) throws VFSException, NamingException {
    mounts.put(new FileName(path).toString(), vfs);
  }
View Full Code Here

  public String createFile(UserCtx ctx, FileInfo file) throws VFSException {
    MountData dat = findFS(file.getFileName());
    if(dat == null)
      return null;

    FileName untranName = file.getFileName();
    file.setFileName(translate(dat, untranName));
    String tag = dat.vfs.createFile(ctx, file);
    file.setFileName(untranName);
    return tag;
  }
View Full Code Here

      throws VFSException {
    MountData dat = findFS(info.filename);
    if(dat == null)
      return null;

    FileName untranName = info.filename;
    info.filename = translate(dat, info.filename);

    FileWriteInfo inf = dat.vfs.write(ctx, info);
    info.filename = untranName;
    return inf;
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.