Package com.blackrook.fs.archive
Class FolderArchive
- java.lang.Object
-
- com.blackrook.fs.FSFileArchive
-
- com.blackrook.fs.archive.FolderArchive
-
public class FolderArchive extends FSFileArchive
This is an FS wrapping class for wrapping a folder on the native file system. NOTE: This will not map hidden files/directories into its lookup table.- Author:
- Matthew Tropiano
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FolderArchive.FolderFile
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,File>
fileLookupTable
Table for file lookup.
-
Constructor Summary
Constructors Constructor Description FolderArchive(File f)
Constructs a new folder archive from a file object.FolderArchive(String path)
Constructs a new folder archive from an abstract path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canCreateFiles()
Can this archive create a new file within itself?OutputStream
createFile(String path)
Creates a file in this archive using the name and path provided.FSFile[]
getAllFiles()
Retrieves all of the files within this object as FSFile objects.FSFile[]
getAllFiles(FSFileFilter filter)
Retrieves all of the files within this object that pass the filter test as FSFile objects.FSFile[]
getAllFilesInDir(String path)
Retrieves all of the files within a directory as FSFile objects.FSFile[]
getAllFilesInDir(String path, FSFileFilter filter)
Retrieves all of the files within this object as FSFile objects that pass the filter test.FSFile
getFile(String path)
Returns an FSFile reference of a file within this wrapped file.-
Methods inherited from class com.blackrook.fs.FSFileArchive
getArchiveName, getPath, setArchiveName, setPath
-
-
-
-
Constructor Detail
-
FolderArchive
public FolderArchive(String path)
Constructs a new folder archive from an abstract path.- Parameters:
path
- a path to a folder on the native file system.- Throws:
FileSystemException
- if the path refers to a location that is not a folder.NullPointerException
- if path is null.
-
FolderArchive
public FolderArchive(File f)
Constructs a new folder archive from a file object.- Parameters:
f
- a file that is a folder on the native file system.- Throws:
FileSystemException
- if the file refers to a location that is not a folder.NullPointerException
- if f is null.
-
-
Method Detail
-
getFile
public FSFile getFile(String path)
Description copied from class:FSFileArchive
Returns an FSFile reference of a file within this wrapped file.- Specified by:
getFile
in classFSFileArchive
- 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.
-
getAllFiles
public FSFile[] getAllFiles()
Description copied from class:FSFileArchive
Retrieves all of the files within this object as FSFile objects.- Specified by:
getAllFiles
in classFSFileArchive
- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
-
getAllFiles
public FSFile[] getAllFiles(FSFileFilter filter)
Description copied from class:FSFileArchive
Retrieves all of the files within this object that pass the filter test as FSFile objects.- Specified by:
getAllFiles
in classFSFileArchive
- Parameters:
filter
- the file filter to use.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
-
getAllFilesInDir
public FSFile[] getAllFilesInDir(String path)
Description copied from class:FSFileArchive
Retrieves all of the files within a directory as FSFile objects.- Specified by:
getAllFilesInDir
in classFSFileArchive
- 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.
-
getAllFilesInDir
public FSFile[] getAllFilesInDir(String path, FSFileFilter filter)
Description copied from class:FSFileArchive
Retrieves all of the files within this object as FSFile objects that pass the filter test.- Specified by:
getAllFilesInDir
in classFSFileArchive
- 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.
-
canCreateFiles
public boolean canCreateFiles()
Description copied from class:FSFileArchive
Can this archive create a new file within itself?- Specified by:
canCreateFiles
in classFSFileArchive
- Returns:
- true if it can, false if it is read-only.
-
createFile
public OutputStream createFile(String path) throws IOException
Description copied from class:FSFileArchive
Creates a file in this archive using the name and path provided.- Specified by:
createFile
in classFSFileArchive
- Parameters:
path
- the path of the file to create.- Returns:
- an acceptable OutputStream for filling the file with data.
- Throws:
IOException
- if a read error occurs during the fetch.
-
-