Package com.mku.fs.file
Interface IVirtualFile
- All Known Implementing Classes:
AesFile
public interface IVirtualFile
A virtual file. Read-only operations are included. Since write operations can be implementation
specific ie for encryption they can be implemented by extending this class.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classDirectory copy options (recursively)static classDirectory move options (recursively)static classDirectory move options (recursively) -
Method Summary
Modifier and TypeMethodDescriptioncopy(IVirtualFile dir) Copy file to another directory.copy(IVirtualFile dir, IFile.CopyOptions options) Copy file to another directory.voidcopyRecursively(IVirtualFile dest) Copy a directory recursivelyvoidcopyRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveCopyOptions options) Copy a directory recursivelycreateDirectory(String dirName) Creates a directory under this directorycreateFile(String filename) Create a file under this directoryvoiddelete()Delete this file.voidDelete all subdirectories and files.voidDelete all subdirectories and files.booleanexists()Returns true if this file existsGet a child with this filename.Retrieves a stream that will be used for reading the file contents.longReturns the last date modified in milliseconds.longReturn the virtual size of the file.getName()Returns the file nameRetrieves a stream that will be used for writing the file contents.Returns the virtual parent directory.getPath()Return the virtual path for this file.Return the real fileReturn the path of the real file.booleanCheck if this is a directory.booleanisFile()Check if this is a file.Lists files and directories under this directoryvoidmkdir()Create this directory.move(IVirtualFile dir) Move file to another directory.move(IVirtualFile dir, IFile.MoveOptions options) Move file to another directory.voidmoveRecursively(IVirtualFile dest) Move a directory recursivelyvoidmoveRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveMoveOptions options) Move a directory recursivelyvoidRename the virtual file name
-
Method Details
-
getInputStream
Retrieves a stream that will be used for reading the file contents.- Returns:
- The input stream
- Throws:
IOException- Thrown if there is an IO error.
-
getOutputStream
Retrieves a stream that will be used for writing the file contents.- Returns:
- The output stream
- Throws:
IOException- Thrown if there is a problem with the stream.
-
listFiles
IVirtualFile[] listFiles()Lists files and directories under this directory- Returns:
- An array of files and subdirectories.
-
getChild
Get a child with this filename.- Parameters:
filename- The filename to search for- Returns:
- The child file
- Throws:
IOException- Thrown if there is an exception.
-
isFile
boolean isFile()Check if this is a file.- Returns:
- True if it is a file.
-
isDirectory
boolean isDirectory()Check if this is a directory.- Returns:
- True if it is a directory.
-
getPath
Return the virtual path for this file.- Returns:
- The virtual path.
- Throws:
IOException- Thrown if there is an IO error.
-
getRealPath
String getRealPath()Return the path of the real file.- Returns:
- The real path.
-
getRealFile
IFile getRealFile()Return the real file- Returns:
- The real file
-
getName
Returns the file name- Returns:
- The file name
- Throws:
IOException- if there was a problem with the stream
-
getParent
IVirtualFile getParent()Returns the virtual parent directory.- Returns:
- The parent directory.
-
delete
void delete()Delete this file. -
mkdir
void mkdir()Create this directory. -
getLastDateModified
long getLastDateModified()Returns the last date modified in milliseconds.- Returns:
- The last date modified in milliseconds.
-
getLength
Return the virtual size of the file.- Returns:
- The size in bytes.
- Throws:
IOException- if there was a problem with the stream
-
exists
boolean exists()Returns true if this file exists- Returns:
- True if exists.
-
createDirectory
Creates a directory under this directory- Parameters:
dirName- The name of the directory to be created- Returns:
- The new directory.
- Throws:
IOException- if there was a problem with the stream
-
createFile
Create a file under this directory- Parameters:
filename- The file name.- Returns:
- The new file.
- Throws:
IOException- if there was a problem with the stream
-
rename
Rename the virtual file name- Parameters:
newFilename- The new filename this file will be renamed to- Throws:
IOException- if there was a problem with the stream
-
move
Move file to another directory.- Parameters:
dir- Target directory.- Returns:
- The file
- Throws:
IOException- Thrown if there is an IO error.
-
move
Move file to another directory.- Parameters:
dir- Target directory.options- The options- Returns:
- The file
- Throws:
IOException- Thrown if there is an IO error.
-
copy
Copy file to another directory.- Parameters:
dir- Target directory.- Returns:
- The file
- Throws:
IOException- Thrown if there is an IO error.
-
copy
Copy file to another directory.- Parameters:
dir- Target directory.options- The options- Returns:
- The file
- Throws:
IOException- Thrown if there is an IO error.
-
copyRecursively
Copy a directory recursively- Parameters:
dest- The destination directory- Throws:
IOException- Thrown if there is an IO error.
-
copyRecursively
void copyRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveCopyOptions options) throws IOException Copy a directory recursively- Parameters:
dest- The destination directoryoptions- The options- Throws:
IOException- Thrown if there is an IO error.
-
moveRecursively
Move a directory recursively- Parameters:
dest- The destination directory- Throws:
IOException- Thrown if there is an IO error.
-
moveRecursively
void moveRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveMoveOptions options) throws IOException Move a directory recursively- Parameters:
dest- The destination directoryoptions- The options- Throws:
IOException- Thrown if there is an IO error.
-
deleteRecursively
void deleteRecursively()Delete all subdirectories and files. -
deleteRecursively
Delete all subdirectories and files.- Parameters:
options- The options
-