Package org.jboss.vfs
Class VFS
- java.lang.Object
-
- org.jboss.vfs.VFS
-
public class VFS extends java.lang.Object
Virtual File System- Version:
- $Revision: 1.1 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
VFS.EmptyRemovableSet<E>
private static class
VFS.LeakDescriptor
(package private) static class
VFS.Mount
The mount representation.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Set
EMPTY_REMOVABLE_SET
private static java.util.concurrent.ConcurrentMap<VirtualFile,java.util.Map<java.lang.String,VFS.Mount>>
mounts
private static VFS.Mount
rootMount
private static VirtualFile
rootVirtualFile
-
Constructor Summary
Constructors Modifier Constructor Description private
VFS()
Do not allow construction
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static VirtualFile
createDefaultRoot()
private static MountHandle
doMount(FileSystem fileSystem, VirtualFile mountPoint, java.io.Closeable... additionalCloseables)
private static <E> java.util.Set<E>
emptyRemovableSet()
static VirtualFile
getChild(java.lang.String path)
Find a virtual file.static VirtualFile
getChild(java.net.URI uri)
Find a virtual file.static VirtualFile
getChild(java.net.URL url)
Deprecated.use getChild(URI) insteadstatic java.util.List<VirtualFile>
getChildren()
Get the childrenstatic java.util.List<VirtualFile>
getChildren(VirtualFileFilter filter)
Get the childrenstatic java.util.List<VirtualFile>
getChildrenRecursively()
Get all the children recursivelystatic java.util.List<VirtualFile>
getChildrenRecursively(VirtualFileFilter filter)
Get all the children recursively(package private) static VFS.Mount
getMount(VirtualFile virtualFile)
static VirtualFile
getRootVirtualFile()
Get the root virtual file for this VFS instance.(package private) static java.util.Set<java.lang.String>
getSubmounts(VirtualFile virtualFile)
Get all immediate submounts for a path.private static void
init()
Initialize VFS protocol handlers package property.private static boolean
isWindows()
static java.io.Closeable
mount(VirtualFile mountPoint, FileSystem fileSystem)
Mount a filesystem on a mount point in the VFS.static java.io.Closeable
mountAssembly(VirtualFileAssembly assembly, VirtualFile mountPoint)
Create and mount an assembly file system, returning a single handle which will unmount and close the filesystem when closed.static java.io.Closeable
mountReal(java.io.File realRoot, VirtualFile mountPoint)
Create and mount a real file system, returning a single handle which will unmount and close the filesystem when closed.static java.io.Closeable
mountTemp(VirtualFile mountPoint, TempFileProvider tempFileProvider)
Create and mount a temporary file system, returning a single handle which will unmount and close the filesystem when closed.static java.io.Closeable
mountZip(java.io.File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider)
Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file system when closed.static java.io.Closeable
mountZip(java.io.InputStream zipData, java.lang.String zipName, VirtualFile mountPoint, TempFileProvider tempFileProvider)
Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file system when closed.static java.io.Closeable
mountZip(VirtualFile zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider)
Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file system when closed.static java.io.Closeable
mountZipExpanded(java.io.File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider)
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.static java.io.Closeable
mountZipExpanded(java.io.InputStream zipData, java.lang.String zipName, VirtualFile mountPoint, TempFileProvider tempFileProvider)
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.static java.io.Closeable
mountZipExpanded(VirtualFile zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider)
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.protected static void
visit(VirtualFile file, VirtualFileVisitor visitor)
Visit the virtual file systemstatic void
visit(VirtualFileVisitor visitor)
Visit the virtual file system from the root
-
-
-
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
-
-
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 pointfileSystem
- 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) insteadFind 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 nulljava.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 recursivelyVisitorAttributes.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 recursivelyVisitorAttributes.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 VFSjava.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 filevisitor
- the visitor- Throws:
java.io.IOException
- for any problem accessing the VFSjava.lang.IllegalArgumentException
- if the file or visitor is null
-
getMount
static VFS.Mount getMount(VirtualFile virtualFile)
-
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 mountmountPoint
- the point at which the filesystem should be mountedtempFileProvider
- 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 datazipName
- the name of the archivemountPoint
- the point at which the filesystem should be mountedtempFileProvider
- 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 VFSmountPoint
- the point at which the filesystem should be mountedtempFileProvider
- 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 rootmountPoint
- 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 mountedtempFileProvider
- 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 mountmountPoint
- the point at which the filesystem should be mountedtempFileProvider
- 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 datazipName
- the name of the archivemountPoint
- the point at which the filesystem should be mountedtempFileProvider
- 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 VFSmountPoint
- the point at which the filesystem should be mountedtempFileProvider
- 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
- anVirtualFileAssembly
to mount in the VFSmountPoint
- 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()
-
-