Package org.apache.commons.vfs2

Examples of org.apache.commons.vfs2.FileSystem


                                                    final FileSystemOptions fileSystemOptions)
        throws FileSystemException
    {
        // Check if cached
        final FileName rootName = file.getName();
        FileSystem fs = findFileSystem(rootName, null);
        if (fs == null)
        {
            // Create the file system
            fs = doCreateFileSystem(scheme, file, fileSystemOptions);
            addFileSystem(rootName, fs);
        }
        return fs.getRoot();
    }
View Full Code Here


        {
            final URL url = new URL(uri);

            URL rootUrl = new URL(url, "/");
            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);
            }
            return fs.resolveFile(url.getPath());
        }
        catch (final MalformedURLException e)
        {
            throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", uri, e);
        }
View Full Code Here

        FileType fileType = UriParser.normalisePath(buffer);
        final String path = buffer.toString();

        // Create the temp file system if it does not exist
        // FileSystem filesystem = findFileSystem( this, (Properties) null);
        FileSystem filesystem = findFileSystem(this, properties);
        if (filesystem == null)
        {
            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);
        }

        // Find the file
        return filesystem.resolveFile(path);
    }
View Full Code Here

        if (caps != null)
        {
            for (int i = 0; i < caps.length; i++)
            {
                final Capability cap = caps[i];
                FileSystem fs = readFolder.getFileSystem();
                if (!fs.hasCapability(cap))
                {
//                    String name = fs.getClass().getName();
//                    int index = name.lastIndexOf('.');
//                    String fsName = (index > 0) ? name.substring(index + 1) : name;
//                    System.out.println("skipping " + getName() + " because " +
View Full Code Here

    /**
     * Tests the contents of root of file system can be listed.
     */
    public void testRoot() throws FileSystemException
    {
        FileSystem fs = getReadFolder().getFileSystem();
        String uri = fs.getRootURI();
        final FileObject file = getManager().resolveFile(uri);
        file.getChildren();
    }
View Full Code Here

    public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
    {
        final FileObject baseFolder = config.getBaseTestFolder(manager);

        // Create an empty file system, then link in the base folder
        final FileSystem newFs = manager.createVirtualFileSystem("vfs:").getFileSystem();
        final String junctionPoint = "/some/dir";
        newFs.addJunction(junctionPoint, baseFolder);

        return newFs.resolveFile(junctionPoint);
    }
View Full Code Here

    /**
     * Tests root of file system exists.
     */
    public void testRoot() throws FileSystemException
    {
        FileSystem fs = getReadFolder().getFileSystem();
        String uri = fs.getRootURI();
        final FileObject file = getManager().resolveFile(uri);
        //final FileObject file = getReadFolder().getFileSystem().getRoot();
        assertTrue(file.exists());
        assertTrue(file.getType() != FileType.IMAGINARY);
    }
View Full Code Here

        assertTrue("child does not exist", !child.exists());
        assertSame(folder, child.getParent());

        // Test the parent of the root of the file system
        // TODO - refactor out test cases for layered vs originating fs
        final FileSystem fileSystem = getReadFolder().getFileSystem();
        FileObject root = fileSystem.getRoot();
        if (fileSystem.getParentLayer() == null)
        {
            // No parent layer, so parent should be null
            assertNull("root has null parent", root.getParent());
        }
        else
        {
            // Parent should be parent of parent layer.
            assertSame(fileSystem.getParentLayer().getParent(), root.getParent());
        }
    }
View Full Code Here

    /**
     * Checks nested junctions are not supported.
     */
    public void testNestedJunction() throws Exception
    {
        final FileSystem fs = getManager().createVirtualFileSystem("vfs:").getFileSystem();
        final FileObject baseDir = getBaseDir();
        fs.addJunction("/a", baseDir);

        // Nested
        try
        {
            fs.addJunction("/a/b", baseDir);
            fail();
        }
        catch (final Exception e)
        {
            assertSameMessage("vfs.impl/nested-junction.error", "vfs:/a/b", e);
        }

        // At same point
        try
        {
            fs.addJunction("/a", baseDir);
            fail();
        }
        catch (final Exception e)
        {
            assertSameMessage("vfs.impl/nested-junction.error", "vfs:/a", e);
View Full Code Here

    /**
     * Checks ancestors are created when a junction is created.
     */
    public void testAncestors() throws Exception
    {
        final FileSystem fs = getManager().createVirtualFileSystem("vfs://").getFileSystem();
        final FileObject baseDir = getBaseDir();

        // Make sure the file at the junction point and its ancestors do not exist
        FileObject file = fs.resolveFile("/a/b");
        assertFalse(file.exists());
        file = file.getParent();
        assertFalse(file.exists());
        file = file.getParent();
        assertFalse(file.exists());

        // Add the junction
        fs.addJunction("/a/b", baseDir);

        // Make sure the file at the junction point and its ancestors exist
        file = fs.resolveFile("/a/b");
        assertTrue("Does not exist", file.exists());
        file = file.getParent();
        assertTrue("Does not exist", file.exists());
        file = file.getParent();
        assertTrue("Does not exist", file.exists());
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.FileSystem

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.