Package org.apache.jackrabbit.core.fs
Class BasedFileSystem
java.lang.Object
org.apache.jackrabbit.core.fs.BasedFileSystem
- All Implemented Interfaces:
FileSystem
A
BasedFileSystem represents a 'file system in a file system'.-
Field Summary
Fields inherited from interface org.apache.jackrabbit.core.fs.FileSystem
SEPARATOR, SEPARATOR_CHAR -
Constructor Summary
ConstructorsConstructorDescriptionBasedFileSystem(FileSystem fsBase, String relRootPath) Creates a newBasedFileSystem -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the file system.voidcreateFolder(String folderPath) Creates the folder named by this path, including any necessary but nonexistent parent folders.voiddeleteFile(String filePath) Deletes the file denoted by this path.voiddeleteFolder(String folderPath) Deletes the folder denoted by this path.booleanTests whether the file system entry denoted by this path exists.getInputStream(String filePath) Returns an input stream of the contents of the file denoted by this path.getOutputStream(String filePath) Returns an output stream for writing bytes to the file denoted by this path.booleanhasChildren(String path) Tests whether the file system entry denoted by this path has child entries.voidinit()Initialize the file systembooleanTests whether the file system entry denoted by this path exists and is a file.booleanTests whether the file system entry denoted by this path exists and is a folder.longlastModified(String path) Returns the time that the file system entry denoted by this path was last modified.longReturns the length of the file denoted by this path.String[]Returns an array of strings naming the files and folders in the folder denoted by this path.String[]Returns an array of strings naming the files in the folder denoted by this path.String[]listFolders(String folderPath) Returns an array of strings naming the folders in the folder denoted by this path.
-
Constructor Details
-
BasedFileSystem
Creates a newBasedFileSystem- Parameters:
fsBase- theFileSystemthe new file system should be based onrelRootPath- the root path relative tofsBase's root
-
-
Method Details
-
init
Initialize the file system- Specified by:
initin interfaceFileSystem- Throws:
FileSystemException- if the file system initialization fails
-
close
Close the file system. After calling this method, the file system is no longer accessible.- Specified by:
closein interfaceFileSystem- Throws:
FileSystemException
-
createFolder
Creates the folder named by this path, including any necessary but nonexistent parent folders. Note that if this operation fails it may have succeeded in creating some of the necessary parent folders.- Specified by:
createFolderin interfaceFileSystem- Parameters:
folderPath- the path of the folder to be created.- Throws:
FileSystemException- if a file system entry denoted by path already exists or if another error occurs.
-
deleteFile
Deletes the file denoted by this path.- Specified by:
deleteFilein interfaceFileSystem- Parameters:
filePath- the path of the file to be deleted.- Throws:
FileSystemException- if this path does not denote a file or if another error occurs.
-
deleteFolder
Deletes the folder denoted by this path. Any contents of this folder (folders and files) will be deleted recursively.- Specified by:
deleteFolderin interfaceFileSystem- Parameters:
folderPath- the path of the folder to be deleted.- Throws:
FileSystemException- if this path does not denote a folder or if another error occurs.
-
exists
Tests whether the file system entry denoted by this path exists.- Specified by:
existsin interfaceFileSystem- Parameters:
path- the path of a file system entry.- Returns:
- true if the file system entry at path exists; false otherwise.
- Throws:
FileSystemException
-
getInputStream
Returns an input stream of the contents of the file denoted by this path.- Specified by:
getInputStreamin interfaceFileSystem- Parameters:
filePath- the path of the file.- Returns:
- an input stream of the contents of the file.
- Throws:
FileSystemException- if the file does not exist or if it cannot be read from
-
getOutputStream
Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. If the file exists, its contents will be overwritten.- Specified by:
getOutputStreamin interfaceFileSystem- Parameters:
filePath- the path of the file.- Returns:
- an output stream for writing bytes to the file.
- Throws:
FileSystemException- if the file cannot be written to or created
-
hasChildren
Tests whether the file system entry denoted by this path has child entries.- Specified by:
hasChildrenin interfaceFileSystem- Parameters:
path- the path of a file system entry.- Returns:
- true if the file system entry at path has child entries; false otherwise.
- Throws:
FileSystemException
-
isFile
Tests whether the file system entry denoted by this path exists and is a file.- Specified by:
isFilein interfaceFileSystem- Parameters:
path- the path of a file system entry.- Returns:
- true if the file system entry at path is a file; false otherwise.
- Throws:
FileSystemException
-
isFolder
Tests whether the file system entry denoted by this path exists and is a folder.- Specified by:
isFolderin interfaceFileSystem- Parameters:
path- the path of a file system entry.- Returns:
- true if the file system entry at path is a folder; false otherwise.
- Throws:
FileSystemException
-
lastModified
Returns the time that the file system entry denoted by this path was last modified.- Specified by:
lastModifiedin interfaceFileSystem- Parameters:
path- the path of a file system entry.- Returns:
- A long value representing the time the file system entry was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the modification time can't be determined.
- Throws:
FileSystemException- if the file system entry does not exist.
-
length
Returns the length of the file denoted by this path.- Specified by:
lengthin interfaceFileSystem- Parameters:
filePath- the path of the file.- Returns:
- The length, in bytes, of the file denoted by this path, or -1L if the length can't be determined.
- Throws:
FileSystemException- if the path does not denote an existing file.
-
list
Returns an array of strings naming the files and folders in the folder denoted by this path.- Specified by:
listin interfaceFileSystem- Parameters:
folderPath- the path of the folder whose contents is to be listed.- Returns:
- an array of strings naming the files and folders in the folder denoted by this path.
- Throws:
FileSystemException- if this path does not denote a folder or if another error occurs.
-
listFiles
Returns an array of strings naming the files in the folder denoted by this path.- Specified by:
listFilesin interfaceFileSystem- Parameters:
folderPath- the path of the folder whose contents is to be listed.- Returns:
- an array of strings naming the files in the folder denoted by this path.
- Throws:
FileSystemException- if this path does not denote a folder or if another error occurs.
-
listFolders
Returns an array of strings naming the folders in the folder denoted by this path.- Specified by:
listFoldersin interfaceFileSystem- Parameters:
folderPath- the path of the folder whose contents is to be listed.- Returns:
- an array of strings naming the folders in the folder denoted by this path.
- Throws:
FileSystemException- if this path does not denote a folder or if another error occurs.
-