Package org.apache.commons.vfs2

Examples of org.apache.commons.vfs2.FileName


        }
        try
        {
            FileSystemManager fsManager = VFS.getManager();

            FileName path;
            if (basePath != null && UriParser.extractScheme(file) == null)
            {
                FileName base = fsManager.resolveURI(basePath);
                path = fsManager.resolveName(base, file);
            }
            else
            {
                path = fsManager.resolveURI(file);
View Full Code Here


            if (!file.exists())
            {
                return null;
            }
            FileName path = file.getName();
            URLStreamHandler handler = new VFSURLStreamHandler(path);
            return new URL(null, path.getURI(), handler);
        }
        catch (FileSystemException fse)
        {
            return null;
        }
View Full Code Here

    {
        final String scheme = "file:";
        final StringBuilder uri = new StringBuilder(name.length() + scheme.length());
        uri.append(scheme);
        uri.append(name);
        final FileName filename = parseUri(null, uri.toString());
        return findFile(filename, null);
    }
View Full Code Here

            final String key = this.getClass().getName() + rootUrl.toString();
            FileSystem fs = findFileSystem(key, fileSystemOptions);
            if (fs == null)
            {
                final 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

        {
            if (rootFile == null)
            {
                rootFile = getContext().getTemporaryFileStore().allocateFile("tempfs");
            }
            final FileName rootName =
                getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);
            // final FileName rootName =
            //    new LocalFileName(scheme, scheme + ":", FileName.ROOT_PATH);
            filesystem = new LocalFileSystem(rootName, rootFile.getAbsolutePath(), properties);
            addFileSystem(this, filesystem);
View Full Code Here

        final Map<FileName, FileObject> files = getOrCreateFilesystemCache(file.getFileSystem());

        writeLock.lock();
        try
        {
            final FileName name = file.getName();

            if (files.containsKey(name))
            {
                return false;
            }
View Full Code Here

     */
    @Override
    protected FileObject createFile(final AbstractFileName name) throws Exception
    {
        // Find the file that the name points to
        final FileName junctionPoint = getJunctionForFile(name);
        final FileObject file;
        if (junctionPoint != null)
        {
            // Resolve the real file
            final FileObject junctionFile = junctions.get(junctionPoint);
            final String relName = junctionPoint.getRelativeName(name);
            file = junctionFile.resolveFile(relName, NameScope.DESCENDENT_OR_SELF);
        }
        else
        {
            file = null;
View Full Code Here

    @Override
    public void addJunction(final String junctionPoint,
                            final FileObject targetFile)
        throws FileSystemException
    {
        final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint);

        // Check for nested junction - these are not supported yet
        if (getJunctionForFile(junctionName) != null)
        {
            throw new FileSystemException("vfs.impl/nested-junction.error", junctionName);
        }

        try
        {
            // Add to junction table
            junctions.put(junctionName, targetFile);

            // Attach to file
            final DelegateFileObject junctionFile = (DelegateFileObject) getFileFromCache(junctionName);
            if (junctionFile != null)
            {
                junctionFile.setFile(targetFile);
            }

            // Create ancestors of junction point
            FileName childName = junctionName;
            boolean done = false;
            for (AbstractFileName parentName = (AbstractFileName) childName.getParent();
                 !done && parentName != null;
                 childName = parentName, parentName = (AbstractFileName) parentName.getParent())
            {
                DelegateFileObject file = (DelegateFileObject) getFileFromCache(parentName);
                if (file == null)
View Full Code Here

     */
    @Override
    public void removeJunction(final String junctionPoint)
        throws FileSystemException
    {
        final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint);
        junctions.remove(junctionName);

        // TODO - remove from parents of junction point
        // TODO - detach all cached children of the junction point from their real file
    }
View Full Code Here

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

TOP

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