Package org.apache.commons.vfs

Examples of org.apache.commons.vfs.FileName


  private GroovyObject getScriptInstance(String scriptFileName) throws IOException, InstantiationException,
      IllegalAccessException, ClassNotFoundException
  {
    FileObject fileObject = VFSUtils.resolveFile(".", scriptFileName);
    FileName fileName = fileObject.getName();
    long lastModified = fileObject.getContent().getLastModifiedTime();
    String scriptName = StringUtils.removeEnd(fileName.getBaseName(), "." + fileName.getExtension()) + "_"
        + lastModified;

    synchronized (GroovyScript.class)
    {
      if (groovyClassLoader == null)
View Full Code Here


    protected FileSystem doCreateFileSystem(final String scheme,
                                            final FileObject file,
                                            final FileSystemOptions fileSystemOptions)
        throws FileSystemException
    {
        final FileName rootName =
            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
        return new TarFileSystem(rootName, file, fileSystemOptions);
    }
View Full Code Here

     */
    public void removeFile(final FileObject file)
    {
        synchronized (this.monitorMap)
        {
            FileName fn = file.getName();
            if (this.monitorMap.get(fn) != null)
            {
                FileObject parent;
                try
                {
View Full Code Here

                fileNames = this.monitorMap.keySet().toArray();
            }
            for (int iterFileNames = 0; iterFileNames < fileNames.length;
                 iterFileNames++)
            {
                FileName fileName = (FileName) fileNames[iterFileNames];
                FileMonitorAgent agent;
                synchronized (this.monitorMap)
                {
                    agent = (FileMonitorAgent) this.monitorMap.get(fileName);
                }
View Full Code Here

  {
    FileSystemManager mgr = VFS.getManager();

    FileObject root = mgr
        .resolveFile("smb://HOME\\vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfsusr");
    FileName rootName = root.getName();
 
    testNames(mgr, rootName);

    testChildren(root);
View Full Code Here

            final String key = this.getClass().getName() + rootUrl.toString();
            FileSystem fs = findFileSystem(key, fileSystemOptions);
            if (fs == null)
            {
                String extForm = rootUrl.toExternalForm();
                final FileName rootName =
                    getContext().parseURI(extForm);
                // final FileName rootName =
                //    new BasicFileName(rootUrl, FileName.ROOT_PATH);
                fs = new UrlFileSystem(rootName, fileSystemOptions);
                addFileSystem(key, fs);
View Full Code Here

        // TODO - use a hashtable when there are a large number of children
        FileObject[] children = getChildren();
        for (int i = 0; i < children.length; i++)
        {
            // final FileObject child = children[i];
            final FileName child = children[i].getName();
            // TODO - use a comparator to compare names
            // if (child.getName().getBaseName().equals(name))
            if (child.getBaseName().equals(name))
            {
                return resolveFile(child);
            }
        }
        return null;
View Full Code Here

     *             absolute path, which is resolved relative to the file system
     *             that contains this file.
     */
    public FileObject resolveFile(final String path) throws FileSystemException
    {
        final FileName otherName = getFileSystem().getFileSystemManager().resolveName(name, path);
        return fs.resolveFile(otherName);
    }
View Full Code Here

     */
    private void notifyParent(FileName childName, FileType newType) throws Exception
    {
        if (parent == null)
        {
            FileName parentName = name.getParent();
            if (parentName != null)
            {
                // Locate the parent, if it is cached
                parent = fs.getFileFromCache(parentName);
            }
View Full Code Here

   * @throws FileSystemException
   */
  public FileName resolveName(final FileName base, final String name,
      final NameScope scope) throws FileSystemException
  {
    final FileName realBase;
    if (base != null && VFS.isUriStyle() && base.getType() == FileType.FILE)
    {
      realBase = base.getParent();
    }
    else
    {
      realBase = base;
    }

    final StringBuffer buffer = new StringBuffer(name);

    // Adjust separators
    UriParser.fixSeparators(buffer);

    // Determine whether to prepend the base path
    if (name.length() == 0 || name.charAt(0) != FileName.SEPARATOR_CHAR)
    {
      // Supplied path is not absolute
      if (!VFS.isUriStyle())
      {
        // when using uris the parent already do have the trailing "/"
        buffer.insert(0, FileName.SEPARATOR_CHAR);
      }
      buffer.insert(0, realBase.getPath());
    }

    // // UriParser.canonicalizePath(buffer, 0, name.length());

    // Normalise the path
    FileType fileType = UriParser.normalisePath(buffer);

    // Check the name is ok
    final String resolvedPath = buffer.toString();
    if (!AbstractFileName
        .checkName(realBase.getPath(), resolvedPath, scope))
    {
      throw new FileSystemException(
          "vfs.provider/invalid-descendent-name.error", name);
    }

    String scheme = realBase.getScheme();
    String fullPath = realBase.getRootURI() + resolvedPath;
    final FileProvider provider = (FileProvider) providers.get(scheme);
    if (provider != null)
    {
      // todo: extend the filename parser to be able to parse
      // only a pathname and take the missing informations from
View Full Code Here

TOP

Related Classes of org.apache.commons.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.