All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class org.jos.fs.util.UnionFileSystem

java.lang.Object
    |
    +----org.jos.fs.util.AbstractFileSystem
            |
            +----org.jos.fs.util.UnionFileSystem

public final class UnionFileSystem
extends AbstractFileSystem
implements FileSystemListener
A virtual file system that "mounts" a number of other file systems at specific paths. Normally, this class isn't used by applications; FSManager handles mounting and the like.

For example (symbolic code, not runnable):

UnionFileSystem ufs = new UnionFileSystem();
ufs.mount("floppy", new FAT(new DiskMedium(0)));
ufs.mount("harddrive", new FAT(new DiskMedium(1)));
ufs.mount("myftpserver", new FTP_FS("ftp.myserver.com"));
ufs.delete("floppy/afile");
ufs.rename("harddrive/localfolder/hello.txt", "myftpserver/hello.txt");
// This actually moves hello.txt to the FTP server
Hmm, almost every method is synchronized. This produces a some overhead, but we have to ensure that a mount or dismount doesn't disturb any regular FS operations occuring at the same time.

UnionFileSystem leaves the case policy of mounted file systems unchanged. The default policy for the mount paths is case-insensitive- case-preserving. This means you can't mount "disk" and "Disk" at the same time. Also, if a file system reports CASEPOLICY_UNKNOWN, it is assumed to be case-insensitive (since an assumption must be made when another FS is mounted inside of a CASEPOLICY_UNKNOWN FS).

TODO: synchronization

TODO: add addSeparator() calls in some methods? (If the mount path of a FS is passed as an argument)

TODO: consequent CS/CI handling, change all methods to tree structure

Version:
JOS-FileSystem 4 Preview (25-Mar-98)
Author:
Stefan Reich
See Also:
FSManager

Constructor Index

 o UnionFileSystem()

Method Index

 o delete(String)
 o dirList(String)
 o entityChanged(FileSystemEvent)
 o entityCreated(FileSystemEvent)
 o entityDeleted(FileSystemEvent)
 o entityRenamed(FileSystemEvent)
 o getBranchInfo(String)
 o getCasePolicyForDir(String)
if dir doesn't exist, the result is undefined
 o getFileInfo(String)
 o getMedium()
 o mkdir(String)
 o mount(String, FileSystem)
 o openFile(String, boolean, boolean)
require: readAccess || writeAccess == true
 o rename(String, String)
The standard JDK File.renameTo() method is able to move files around, even between different (Windows) drives; to model this functionality, we need to do real copying
 o unmount(String)

Constructors

 o UnionFileSystem
public UnionFileSystem()

Methods

 o getCasePolicyForDir
public int getCasePolicyForDir(String dir)
if dir doesn't exist, the result is undefined

 o getBranchInfo
public FSBranchInfo getBranchInfo(String branch)
 o getMedium
public Medium getMedium()
 o getFileInfo
public FSFileInfo getFileInfo(String path) throws IOException
 o delete
public void delete(String path) throws IOException
 o rename
public void rename(String from,
                   String to) throws IOException
The standard JDK File.renameTo() method is able to move files around, even between different (Windows) drives; to model this functionality, we need to do real copying

 o mkdir
public void mkdir(String path) throws IOException
 o dirList
public String[] dirList(String path) throws IOException
 o openFile
public FSFile openFile(String file,
                       boolean readAccess,
                       boolean writeAccess) throws IOException
require: readAccess || writeAccess == true

Returns:
opened file (not null)
 o mount
public void mount(String path,
                  FileSystem fs) throws FSException
 o unmount
public void unmount(String path) throws FSException
 o entityCreated
public void entityCreated(FileSystemEvent evt)
 o entityDeleted
public void entityDeleted(FileSystemEvent evt)
 o entityRenamed
public void entityRenamed(FileSystemEvent evt)
 o entityChanged
public void entityChanged(FileSystemEvent evt)

All Packages  Class Hierarchy  This Package  Previous  Next  Index