Examples of FileObject


Examples of org.apache.commons.vfs.FileObject

            {
                throw new FileSystemException("vfs.provider/create-folder-read-only.error", name);
            }

            // Traverse up the heirarchy and make sure everything is a folder
            final FileObject parent = getParent();
            if (parent != null)
            {
                parent.createFolder();
            }

            try
            {
                // Create the folder
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

        // Copy everything across
        final int count = files.size();
        for (int i = 0; i < count; i++)
        {
            final FileObject srcFile = (FileObject) files.get(i);

            // Determine the destination file
            final String relPath = file.getName().getRelativeName(srcFile.getName());
            final FileObject destFile = resolveFile(relPath, NameScope.DESCENDENT_OR_SELF);

            // Clean up the destination file, if necessary
            if (destFile.exists() && destFile.getType() != srcFile.getType())
            {
                // The destination file exists, and is not of the same type,
                // so delete it
                // TODO - add a pluggable policy for deleting and overwriting existing files
                destFile.delete(Selectors.SELECT_ALL);
            }

            // Copy across
            try
            {
                if (srcFile.getType().hasContent())
                {
                    FileUtil.copyContent(srcFile, destFile);
                }
                else if (srcFile.getType().hasChildren())
                {
                    destFile.createFolder();
                }
            }
            catch (final IOException e)
            {
                throw new FileSystemException("vfs.provider/copy-file.error", new Object[]{srcFile, destFile}, e);
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

        }

        if (getType() == FileType.IMAGINARY)
        {
// Does not exist - make sure parent does
            FileObject parent = getParent();
            if (parent != null)
            {
                parent.createFolder();
            }
        }

// Get the raw output stream
        try
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

                                 final boolean depthwise,
                                 final List selected)
        throws Exception
    {
        // Check the file itself
        final FileObject file = fileInfo.getFile();
        final int index = selected.size();

        // If the file is a folder, traverse it
        if (file.getType().hasChildren() && selector.traverseDescendents(fileInfo))
        {
            final int curDepth = fileInfo.getDepth();
            fileInfo.setDepth(curDepth + 1);

            // Traverse the children
            final FileObject[] children = file.getChildren();
            for (int i = 0; i < children.length; i++)
            {
                final FileObject child = children[i];
                fileInfo.setFile(child);
                traverse(fileInfo, selector, depthwise, selected);
            }

            fileInfo.setFile(file);
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

        if (url == null)
        {
            throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", uri);
        }

        FileObject fo = getContext().getFileSystemManager().resolveFile(url.toExternalForm());
        return fo;
    }
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

        {
            buf.insert(0, ":");
            buf.insert(0, schemes[iterSchemes]);
        }

        FileObject fo = getContext().getFileSystemManager().resolveFile(buf.toString(), fileSystemOptions);
        return fo;
    }
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

    }

    protected URLConnection openConnection(final URL url)
        throws IOException
    {
        final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions);
        return new DefaultURLConnection(url, entry.getContent());
    }
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

                            final int start,
                            final int limit)
    {
        try
        {
            FileObject old = context.resolveFile(u.toExternalForm(), fileSystemOptions);

            FileObject newURL;
            if (start > 0 && spec.charAt(start - 1) == ':')
            {
                newURL = context.resolveFile(old, spec, fileSystemOptions);
            }
            else
            {
                if (old.getType() == FileType.FILE && old.getParent() != null)
                {
                    // for files we have to resolve relative
                    newURL = old.getParent().resolveFile(spec);
                }
                else
                {
                    newURL = old.resolveFile(spec);
                }
            }

            final String url = newURL.getName().getURI();
            final StringBuffer filePart = new StringBuffer();
            final String protocolPart = UriParser.extractScheme(url, filePart);

            setURL(u, protocolPart, "", -1, null, null, filePart.toString(), null, null);
        }
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

        // Make the URI canonical

        // Resolve the outer file name
        final FileName fileName = name.getOuterName();
        final FileObject file = getContext().resolveFile(baseFile, fileName.getURI(), properties);

        // Create the file system
        final FileObject rootFile = createFileSystem(name.getScheme(), file, properties);

        // Resolve the file
        return rootFile.resolveFile(name.getPath());
    }
View Full Code Here

Examples of org.apache.commons.vfs.FileObject

    public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
    {
        // Locate the Jar file
        final File outerFile = AbstractVfsTestCase.getTestResource("nested.jar");
        final String uri = "jar:" + outerFile.getAbsolutePath() + "!/test.jar";
        final FileObject jarFile = manager.resolveFile(uri);

        // Now build the nested file system
        final FileObject nestedFS = manager.createFileSystem(jarFile);
        return nestedFS.resolveFile("/");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.