com.zipxap.vfs
Class VirtualFileSystem

java.lang.Object
  extended by com.zipxap.vfs.VirtualFileSystem

public class VirtualFileSystem
extends java.lang.Object

This class is the typical entry-point for working with virtual file systems.

MilestoneWhoDate, Time
Initial VersionK PenroseJune 2009

** Note that this table is not intended as an exhaustive list of subtle changes. It is intended to list changes that break the compatibility of older code, or major enhancements/rewrites


Field Summary
static boolean DEFAULT_USE_COMPRESSION
           
 
Constructor Summary
VirtualFileSystem(java.io.File archiveFile, boolean createIfNecessary, boolean synchronousMode, java.lang.String userId)
           
VirtualFileSystem(java.io.File archiveFile, boolean createIfNecessary, boolean synchronousMode, java.lang.String userId, boolean lockArchiveFile)
           
VirtualFileSystem(java.io.File archiveFile, boolean createIfNecessary, boolean synchronousMode, java.lang.String userId, boolean complainIfNotAVirtualFileSystemFile, boolean useCompression, CipherSettings cipherSettings, boolean lockArchiveFile)
           
 
Method Summary
 void addReindexListener(VFSReindexListener listener)
          Add a reindex listener
 void close()
          Close the virtual file system
 void close(boolean condenseBeforeClose)
          Close the virtual file system
 java.lang.Long condense()
          Shrink the virtual file system down as much as possible by filling in empty sectors with full sectors from the end of the file, and dropping trailing empty sectors.
static java.lang.String convertToValidFilename(java.lang.String filename)
          Converts the specified filename to a valid filename.
 void copyArchive(java.io.File outputFile, CipherSettings cipherSettings)
          Create a new copy of this archive.
 void defrag()
          This does a hard-core defrag of this virtual file system by copying it, entry by entry, to a new file, and then replacing the original file with the copy.
 java.io.File getArchiveFile()
           
 VFSFile getFile(java.lang.String filePath)
          Retrieve the file at the specified path.
 java.lang.String getPasswordHint()
           
 VFSReindexListener[] getReindexListeners()
          Get all of the reindex listeners.
 VFSRepository getRepository(java.lang.String path)
          Get the VFSRepository at the specified path.
 VFSRepository getRootRepository()
           
 java.lang.String getUserId()
           
static boolean isLocked(java.io.File archiveFile)
          Determine if the specified archive file has already been locked by another instance of the VFS.
 boolean isValidated()
           
static boolean isValidFilename(java.lang.String filename)
          Returns message if invalid, else null if valid.
 boolean isVirtualFileSystem()
           
 void reindexFileSystem()
           
static void removeLock(java.io.File archiveFile)
          Be careful with this method, it does no checking and is thus very dangerous.
 boolean removeReindexListener(VFSReindexListener listener)
          Remove a reindex listener.
 void setCipherSettings(CipherSettings newCipherSettings)
           
 void setPassword(java.lang.String password)
           
 void setPasswordHint(java.lang.String passwordHint)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_USE_COMPRESSION

public static final boolean DEFAULT_USE_COMPRESSION
See Also:
Constant Field Values
Constructor Detail

VirtualFileSystem

public VirtualFileSystem(java.io.File archiveFile,
                         boolean createIfNecessary,
                         boolean synchronousMode,
                         java.lang.String userId)

VirtualFileSystem

public VirtualFileSystem(java.io.File archiveFile,
                         boolean createIfNecessary,
                         boolean synchronousMode,
                         java.lang.String userId,
                         boolean lockArchiveFile)
Parameters:
archiveFile -
createIfNecessary -
synchronousMode -
userId -
lockArchiveFile - Be very careful. If this is set to false and another VFS instance opens the same archive and writes to it, the archive will become corrupted.

VirtualFileSystem

public VirtualFileSystem(java.io.File archiveFile,
                         boolean createIfNecessary,
                         boolean synchronousMode,
                         java.lang.String userId,
                         boolean complainIfNotAVirtualFileSystemFile,
                         boolean useCompression,
                         CipherSettings cipherSettings,
                         boolean lockArchiveFile)
Parameters:
archiveFile -
createIfNecessary -
synchronousMode -
userId -
complainIfNotAVirtualFileSystemFile -
useCompression -
cipherSettings - The cipher settings to use, if this VFS is encrypted, else null if it is not encrypted.
Method Detail

removeLock

public static void removeLock(java.io.File archiveFile)
Be careful with this method, it does no checking and is thus very dangerous.

Parameters:
archiveFile -

isLocked

public static boolean isLocked(java.io.File archiveFile)
Determine if the specified archive file has already been locked by another instance of the VFS.

Returns:
true if the specified archive file has already been locked by another instance of the VFS, else false.

setPasswordHint

public void setPasswordHint(java.lang.String passwordHint)

setCipherSettings

public void setCipherSettings(CipherSettings newCipherSettings)

setPassword

public void setPassword(java.lang.String password)

getPasswordHint

public java.lang.String getPasswordHint()

isValidated

public boolean isValidated()

defrag

public void defrag()
This does a hard-core defrag of this virtual file system by copying it, entry by entry, to a new file, and then replacing the original file with the copy. It creates


isVirtualFileSystem

public boolean isVirtualFileSystem()

getUserId

public java.lang.String getUserId()

reindexFileSystem

public void reindexFileSystem()

getRootRepository

public VFSRepository getRootRepository()
Returns:
the root repository

getRepository

public VFSRepository getRepository(java.lang.String path)
Get the VFSRepository at the specified path.

Parameters:
path -
Returns:
The VFSRepository for the specified repositoryPath, or null if it could not be found.

getFile

public VFSFile getFile(java.lang.String filePath)
Retrieve the file at the specified path.

Parameters:
filePath -
Returns:
the file at the specified path

getArchiveFile

public java.io.File getArchiveFile()
Returns:
the archive File associated with this VirtualFileSystem

close

public void close()
Close the virtual file system


close

public void close(boolean condenseBeforeClose)
Close the virtual file system


condense

public java.lang.Long condense()
Shrink the virtual file system down as much as possible by filling in empty sectors with full sectors from the end of the file, and dropping trailing empty sectors.


addReindexListener

public void addReindexListener(VFSReindexListener listener)
Add a reindex listener

Parameters:
listener -

getReindexListeners

public VFSReindexListener[] getReindexListeners()
Get all of the reindex listeners.

Returns:
An array of VFSReindexListener objects.

removeReindexListener

public boolean removeReindexListener(VFSReindexListener listener)
Remove a reindex listener.

Parameters:
listener -
Returns:
true if the specified listener was registered to this virtual file system and was removed, else false if the specified listener was not registered to this virtual file system.

copyArchive

public void copyArchive(java.io.File outputFile,
                        CipherSettings cipherSettings)
Create a new copy of this archive. This method has the side effect of defragmenting a virtual file system.

Parameters:
outputFile -
cipherSettings -

isValidFilename

public static boolean isValidFilename(java.lang.String filename)
Returns message if invalid, else null if valid.

Parameters:
filename -
errorMessage -
propertyName -
Returns:

convertToValidFilename

public static java.lang.String convertToValidFilename(java.lang.String filename)
Converts the specified filename to a valid filename.

Parameters:
filename -
errorMessage -
propertyName -
Returns:
the specified filename if it was valid, else a mangled version that is valid.