Package com.bc.ceres.core
Class VirtualDir
java.lang.Object
com.bc.ceres.core.VirtualDir
A read-only directory that can either be a directory in the file system or a ZIP-file.
Files having '.gz' extensions are automatically decompressed.
- Since:
- Ceres 0.11
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
abstract void
close()
Closes access to this virtual directory.static VirtualDir
Creates an instance of a virtual directory object from a given directory or ZIP-file.static File
static void
deleteFileTree
(File treeRoot) Deletes the directorytreeRoot
and all the content recursively.abstract boolean
protected void
finalize()
abstract File
abstract String
abstract File
Gets the file for the given relative path.abstract InputStream
getInputStream
(String path) Opens an input stream for the given relative file path.Opens a reader for the given relative path.abstract boolean
abstract boolean
abstract String[]
Returns an array of strings naming the files and directories in the directory denoted by the given relative directory path.abstract String[]
Returns an array of strings naming the relative directory path of all file names.
-
Constructor Details
-
VirtualDir
public VirtualDir()
-
-
Method Details
-
getBasePath
- Returns:
- The base path name of the directory.
-
getBaseFile
- Returns:
- The File object of the directory.
-
getReader
Opens a reader for the given relative path.- Parameters:
path
- The relative file path.- Returns:
- A reader for the specified relative path.
- Throws:
IOException
- If the file does not exist or if it can't be opened for reading.
-
getInputStream
Opens an input stream for the given relative file path. Files having '.gz' extensions are automatically decompressed.- Parameters:
path
- The relative file path.- Returns:
- An input stream for the specified relative path.
- Throws:
IOException
- If the file does not exist or if it can't be opened for reading.
-
getFile
Gets the file for the given relative path.- Parameters:
path
- The relative file or directory path.- Returns:
- Gets the file or directory for the specified file path.
- Throws:
IOException
- If the file or directory does not exist or if it can't be extracted from a ZIP-file.
-
list
Returns an array of strings naming the files and directories in the directory denoted by the given relative directory path.There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
- Parameters:
path
- The relative directory path.- Returns:
- An array of strings naming the files and directories in the directory denoted by the given relative directory path. The array will be empty if the directory is empty.
- Throws:
IOException
- If the directory given by the relative path does not exists.
-
exists
-
listAllFiles
Returns an array of strings naming the relative directory path of all file names.There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
- Returns:
- An array of strings naming the relative directory path and filename to all files. The array will be empty if the directory is empty.
- Throws:
IOException
- If an I/O error is thrown when accessing the virtual dir.
-
close
public abstract void close()Closes access to this virtual directory. -
create
Creates an instance of a virtual directory object from a given directory or ZIP-file.- Parameters:
file
- A directory or a ZIP-file.- Returns:
- The virtual directory instance, or
null
iffile
is not a directory or a ZIP-file or the ZIP-file could not be opened for read access..
-
isCompressed
public abstract boolean isCompressed() -
isArchive
public abstract boolean isArchive() -
getTempDir
- Throws:
IOException
-
finalize
-
deleteFileTree
Deletes the directorytreeRoot
and all the content recursively.- Parameters:
treeRoot
- directory to be deleted
-
createUniqueTempDir
- Throws:
IOException
-
clearTempFiles
- Throws:
IOException
-