Package org.jboss.vfs

Class VFS


  • public class VFS
    extends java.lang.Object
    Virtual File System
    Version:
    $Revision: 1.1 $
    • Field Detail

      • mounts

        private static final java.util.concurrent.ConcurrentMap<VirtualFile,​java.util.Map<java.lang.String,​VFS.Mount>> mounts
      • rootVirtualFile

        private static final VirtualFile rootVirtualFile
      • rootMount

        private static final VFS.Mount rootMount
      • EMPTY_REMOVABLE_SET

        private static final java.util.Set EMPTY_REMOVABLE_SET
    • Constructor Detail

      • VFS

        private VFS()
        Do not allow construction
    • Method Detail

      • createDefaultRoot

        private static VirtualFile createDefaultRoot()
      • init

        private static void init()
        Initialize VFS protocol handlers package property.
      • mount

        public static java.io.Closeable mount​(VirtualFile mountPoint,
                                              FileSystem fileSystem)
                                       throws java.io.IOException
        Mount a filesystem on a mount point in the VFS. The mount point is any valid file name, existent or non-existent. If a relative path is given, it will be treated as relative to the VFS root.
        Parameters:
        mountPoint - the mount point
        fileSystem - the file system to mount
        Returns:
        a handle which can be used to unmount the filesystem
        Throws:
        java.io.IOException - if an I/O error occurs, such as a filesystem already being mounted at the given mount point
      • getChild

        @Deprecated
        public static VirtualFile getChild​(java.net.URL url)
                                    throws java.net.URISyntaxException
        Deprecated.
        use getChild(URI) instead
        Find a virtual file.
        Parameters:
        url - the URL whose path component is the child path
        Returns:
        the child
        Throws:
        java.lang.IllegalArgumentException - if the path is null
        java.net.URISyntaxException - for any uri error
      • isWindows

        private static boolean isWindows()
      • getChild

        public static VirtualFile getChild​(java.net.URI uri)
        Find a virtual file.
        Parameters:
        uri - the URI whose path component is the child path
        Returns:
        the child
        Throws:
        java.lang.IllegalArgumentException - if the path is null
      • getChild

        public static VirtualFile getChild​(java.lang.String path)
        Find a virtual file.
        Parameters:
        path - the child path
        Returns:
        the child
        Throws:
        java.lang.IllegalArgumentException - if the path is null
      • getRootVirtualFile

        public static VirtualFile getRootVirtualFile()
        Get the root virtual file for this VFS instance.
        Returns:
        the root virtual file
      • getChildren

        public static java.util.List<VirtualFile> getChildren()
                                                       throws java.io.IOException
        Get the children
        Returns:
        the children
        Throws:
        java.io.IOException - for any problem accessing the virtual file system
      • getChildren

        public static java.util.List<VirtualFile> getChildren​(VirtualFileFilter filter)
                                                       throws java.io.IOException
        Get the children
        Parameters:
        filter - to filter the children
        Returns:
        the children
        Throws:
        java.io.IOException - for any problem accessing the virtual file system
      • getChildrenRecursively

        public static java.util.List<VirtualFile> getChildrenRecursively()
                                                                  throws java.io.IOException
        Get all the children recursively

        This always uses VisitorAttributes.RECURSE

        Returns:
        the children
        Throws:
        java.io.IOException - for any problem accessing the virtual file system
      • getChildrenRecursively

        public static java.util.List<VirtualFile> getChildrenRecursively​(VirtualFileFilter filter)
                                                                  throws java.io.IOException
        Get all the children recursively

        This always uses VisitorAttributes.RECURSE

        Parameters:
        filter - to filter the children
        Returns:
        the children
        Throws:
        java.io.IOException - for any problem accessing the virtual file system
      • visit

        public static void visit​(VirtualFileVisitor visitor)
                          throws java.io.IOException
        Visit the virtual file system from the root
        Parameters:
        visitor - the visitor
        Throws:
        java.io.IOException - for any problem accessing the VFS
        java.lang.IllegalArgumentException - if the visitor is null
      • visit

        protected static void visit​(VirtualFile file,
                                    VirtualFileVisitor visitor)
                             throws java.io.IOException
        Visit the virtual file system
        Parameters:
        file - the file
        visitor - the visitor
        Throws:
        java.io.IOException - for any problem accessing the VFS
        java.lang.IllegalArgumentException - if the file or visitor is null
      • getSubmounts

        static java.util.Set<java.lang.String> getSubmounts​(VirtualFile virtualFile)
        Get all immediate submounts for a path.
        Parameters:
        virtualFile - the path
        Returns:
        the collection of present mount (simple) names
      • doMount

        private static MountHandle doMount​(FileSystem fileSystem,
                                           VirtualFile mountPoint,
                                           java.io.Closeable... additionalCloseables)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • mountZip

        public static java.io.Closeable mountZip​(java.io.File zipFile,
                                                 VirtualFile mountPoint,
                                                 TempFileProvider tempFileProvider)
                                          throws java.io.IOException
        Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file system when closed.
        Parameters:
        zipFile - the zip file to mount
        mountPoint - the point at which the filesystem should be mounted
        tempFileProvider - the temporary file provider
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountZip

        public static java.io.Closeable mountZip​(java.io.InputStream zipData,
                                                 java.lang.String zipName,
                                                 VirtualFile mountPoint,
                                                 TempFileProvider tempFileProvider)
                                          throws java.io.IOException
        Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file system when closed.
        Parameters:
        zipData - an input stream containing the zip data
        zipName - the name of the archive
        mountPoint - the point at which the filesystem should be mounted
        tempFileProvider - the temporary file provider
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountZip

        public static java.io.Closeable mountZip​(VirtualFile zipFile,
                                                 VirtualFile mountPoint,
                                                 TempFileProvider tempFileProvider)
                                          throws java.io.IOException
        Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file system when closed.
        Parameters:
        zipFile - a zip file in the VFS
        mountPoint - the point at which the filesystem should be mounted
        tempFileProvider - the temporary file provider
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountReal

        public static java.io.Closeable mountReal​(java.io.File realRoot,
                                                  VirtualFile mountPoint)
                                           throws java.io.IOException
        Create and mount a real file system, returning a single handle which will unmount and close the filesystem when closed.
        Parameters:
        realRoot - the real filesystem root
        mountPoint - the point at which the filesystem should be mounted
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountTemp

        public static java.io.Closeable mountTemp​(VirtualFile mountPoint,
                                                  TempFileProvider tempFileProvider)
                                           throws java.io.IOException
        Create and mount a temporary file system, returning a single handle which will unmount and close the filesystem when closed.
        Parameters:
        mountPoint - the point at which the filesystem should be mounted
        tempFileProvider - the temporary file provider
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountZipExpanded

        public static java.io.Closeable mountZipExpanded​(java.io.File zipFile,
                                                         VirtualFile mountPoint,
                                                         TempFileProvider tempFileProvider)
                                                  throws java.io.IOException
        Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and close the filesystem when closed.
        Parameters:
        zipFile - the zip file to mount
        mountPoint - the point at which the filesystem should be mounted
        tempFileProvider - the temporary file provider
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountZipExpanded

        public static java.io.Closeable mountZipExpanded​(java.io.InputStream zipData,
                                                         java.lang.String zipName,
                                                         VirtualFile mountPoint,
                                                         TempFileProvider tempFileProvider)
                                                  throws java.io.IOException
        Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and close the filesystem when closed. The given zip data stream is closed.
        Parameters:
        zipData - an input stream containing the zip data
        zipName - the name of the archive
        mountPoint - the point at which the filesystem should be mounted
        tempFileProvider - the temporary file provider
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountZipExpanded

        public static java.io.Closeable mountZipExpanded​(VirtualFile zipFile,
                                                         VirtualFile mountPoint,
                                                         TempFileProvider tempFileProvider)
                                                  throws java.io.IOException
        Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and close the filesystem when closed. The given zip data stream is closed.
        Parameters:
        zipFile - a zip file in the VFS
        mountPoint - the point at which the filesystem should be mounted
        tempFileProvider - the temporary file provider
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • mountAssembly

        public static java.io.Closeable mountAssembly​(VirtualFileAssembly assembly,
                                                      VirtualFile mountPoint)
                                               throws java.io.IOException
        Create and mount an assembly file system, returning a single handle which will unmount and close the filesystem when closed.
        Parameters:
        assembly - an VirtualFileAssembly to mount in the VFS
        mountPoint - the point at which the filesystem should be mounted
        Returns:
        a handle
        Throws:
        java.io.IOException - if an error occurs
      • emptyRemovableSet

        private static <E> java.util.Set<E> emptyRemovableSet()