Package org.jboss.vfs

Class VFS

java.lang.Object
org.jboss.vfs.VFS

public class VFS extends Object
Virtual File System
Version:
$Revision: 1.1 $
  • Field Details

  • Constructor Details

    • VFS

      private VFS()
      Do not allow construction
  • Method Details

    • createDefaultRoot

      private static VirtualFile createDefaultRoot()
    • init

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

      public static Closeable mount(VirtualFile mountPoint, FileSystem fileSystem) throws 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:
      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(URL url) throws 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:
      IllegalArgumentException - if the path is null
      URISyntaxException - for any uri error
    • isWindows

      private static boolean isWindows()
    • getChild

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

      public static VirtualFile getChild(String path)
      Find a virtual file.
      Parameters:
      path - the child path
      Returns:
      the child
      Throws:
      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 List<VirtualFile> getChildren() throws IOException
      Get the children
      Returns:
      the children
      Throws:
      IOException - for any problem accessing the virtual file system
    • getChildren

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

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

      This always uses VisitorAttributes.RECURSE

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

      public static List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter) throws IOException
      Get all the children recursively

      This always uses VisitorAttributes.RECURSE

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

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

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

      static VFS.Mount getMount(VirtualFile virtualFile)
    • getSubmounts

      static Set<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, Closeable... additionalCloseables) throws IOException
      Throws:
      IOException
    • mountZip

      public static Closeable mountZip(File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws 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:
      IOException - if an error occurs
    • mountZip

      public static Closeable mountZip(InputStream zipData, String zipName, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws 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:
      IOException - if an error occurs
    • mountZip

      public static Closeable mountZip(VirtualFile zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws 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:
      IOException - if an error occurs
    • mountReal

      public static Closeable mountReal(File realRoot, VirtualFile mountPoint) throws 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:
      IOException - if an error occurs
    • mountTemp

      public static Closeable mountTemp(VirtualFile mountPoint, TempFileProvider tempFileProvider) throws 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:
      IOException - if an error occurs
    • mountZipExpanded

      public static Closeable mountZipExpanded(File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws 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:
      IOException - if an error occurs
    • mountZipExpanded

      public static Closeable mountZipExpanded(InputStream zipData, String zipName, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws 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:
      IOException - if an error occurs
    • mountZipExpanded

      public static Closeable mountZipExpanded(VirtualFile zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws 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:
      IOException - if an error occurs
    • mountAssembly

      public static Closeable mountAssembly(VirtualFileAssembly assembly, VirtualFile mountPoint) throws 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:
      IOException - if an error occurs
    • emptyRemovableSet

      private static <E> Set<E> emptyRemovableSet()