Class FSFileArchive
java.lang.Object
com.blackrook.fs.FSFileArchive
- Direct Known Subclasses:
ClasspathArchive, FolderArchive, ZipArchive
Wrapper structure that is used to create a common interface with all files.
A wrapper class should be used to wrap an archive or directory type in order for the
file system to be able to read it without needing to know what kind of file it is looking
in.
- Author:
- Matthew Tropiano
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanCan this archive create a new file within itself?abstract OutputStreamcreateFile(String path) Creates a file in this archive using the name and path provided.abstract FSFile[]Retrieves all of the files within this object as FSFile objects.abstract FSFile[]getAllFiles(FSFileFilter filter) Retrieves all of the files within this object that pass the filter test as FSFile objects.abstract FSFile[]getAllFilesInDir(String path) Retrieves all of the files within a directory as FSFile objects.abstract FSFile[]getAllFilesInDir(String path, FSFileFilter filter) Retrieves all of the files within this object as FSFile objects that pass the filter test.Gets the name of this archive.abstract FSFileReturns an FSFile reference of a file within this wrapped file.getPath()Gets the path of this archive.protected voidsetArchiveName(String name) Sets the name of this archive.protected voidSets the path of this archive.
-
Constructor Details
-
FSFileArchive
public FSFileArchive()
-
-
Method Details
-
getFile
Returns an FSFile reference of a file within this wrapped file.- Parameters:
path- the abstract path of a file inside this file.- Returns:
- a new reference to the file requested, or null if the path refers to a location that is not inside this file.
- Throws:
IOException- if a read error occurs during the fetch.
-
getAllFiles
Retrieves all of the files within this object as FSFile objects.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException- if a read error occurs during the fetch.
-
getAllFilesInDir
Retrieves all of the files within a directory as FSFile objects.- Parameters:
path- the abstract path of a directory inside this file.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException- if a read error occurs during the fetch.
-
getAllFilesInDir
Retrieves all of the files within this object as FSFile objects that pass the filter test.- Parameters:
path- the abstract path of a directory inside this file.filter- the file filter to use.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException- if a read error occurs during the fetch.
-
getAllFiles
Retrieves all of the files within this object that pass the filter test as FSFile objects.- Parameters:
filter- the file filter to use.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException- if a read error occurs during the fetch.
-
canCreateFiles
public abstract boolean canCreateFiles()Can this archive create a new file within itself?- Returns:
- true if it can, false if it is read-only.
-
createFile
Creates a file in this archive using the name and path provided.- Parameters:
path- the path of the file to create.- Returns:
- an acceptable OutputStream for filling the file with data.
- Throws:
UnsupportedOperationException- if this is called on an archive that does not support writing.IOException- if a read error occurs during the fetch.
-
setArchiveName
Sets the name of this archive.- Parameters:
name- the new archive name.
-
setPath
Sets the path of this archive.- Parameters:
path- the new archive name.
-
getArchiveName
-
getPath
-