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 Classes Modifier and Type Interface Description static class
IVirtualFile.VirtualRecursiveCopyOptions
Directory copy options (recursively)static class
IVirtualFile.VirtualRecursiveDeleteOptions
Directory move options (recursively)static class
IVirtualFile.VirtualRecursiveMoveOptions
Directory move options (recursively)
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IVirtualFile
copy(IVirtualFile dir)
Copy file to another directory.IVirtualFile
copy(IVirtualFile dir, IFile.CopyOptions options)
Copy file to another directory.void
copyRecursively(IVirtualFile dest)
Copy a directory recursivelyvoid
copyRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveCopyOptions options)
Copy a directory recursivelyIVirtualFile
createDirectory(java.lang.String dirName)
Creates a directory under this directoryIVirtualFile
createFile(java.lang.String filename)
Create a file under this directoryvoid
delete()
Delete this file.void
deleteRecursively()
Delete all subdirectories and files.void
deleteRecursively(IVirtualFile.VirtualRecursiveDeleteOptions options)
Delete all subdirectories and files.boolean
exists()
Returns true if this file existsIVirtualFile
getChild(java.lang.String filename)
Get a child with this filename.RandomAccessStream
getInputStream()
Retrieves a stream that will be used for reading the file contents.long
getLastDateModified()
Returns the last date modified in milliseconds.long
getLength()
Return the virtual size of the file.java.lang.String
getName()
Returns the file nameRandomAccessStream
getOutputStream()
Retrieves a stream that will be used for writing the file contents.IVirtualFile
getParent()
Returns the virtual parent directory.java.lang.String
getPath()
Return the virtual path for this file.IFile
getRealFile()
Return the real filejava.lang.String
getRealPath()
Return the path of the real file.boolean
isDirectory()
Check if this is a directory.boolean
isFile()
Check if this is a file.IVirtualFile[]
listFiles()
Lists files and directories under this directoryvoid
mkdir()
Create this directory.IVirtualFile
move(IVirtualFile dir)
Move file to another directory.IVirtualFile
move(IVirtualFile dir, IFile.MoveOptions options)
Move file to another directory.void
moveRecursively(IVirtualFile dest)
Move a directory recursivelyvoid
moveRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveMoveOptions options)
Move a directory recursivelyvoid
rename(java.lang.String newFilename)
Rename the virtual file name
-
-
-
Method Detail
-
getInputStream
RandomAccessStream getInputStream() throws java.io.IOException
Retrieves a stream that will be used for reading the file contents.- Returns:
- The input stream
- Throws:
java.io.IOException
- Thrown if there is an IO error.SecurityException
- Thrown if there is a security exceptionIntegrityException
- Thrown if the data are corrupt or tampered with.
-
getOutputStream
RandomAccessStream getOutputStream() throws java.io.IOException
Retrieves a stream that will be used for writing the file contents.- Returns:
- The output stream
- Throws:
java.io.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
IVirtualFile getChild(java.lang.String filename) throws java.io.IOException
Get a child with this filename.- Parameters:
filename
- The filename to search for- Returns:
- The child file
- Throws:
SecurityException
- Thrown if there is a security exceptionIntegrityException
- Thrown if the data are corrupt or tampered with.java.io.IOException
- Thrown if there is an IO error.AuthException
- Thrown if there is an Authorization error
-
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
java.lang.String getPath() throws java.io.IOException
Return the virtual path for this file.- Returns:
- The virtual path.
- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
getRealPath
java.lang.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
java.lang.String getName() throws java.io.IOException
Returns the file name- Returns:
- The file name
- Throws:
java.io.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
long getLength() throws java.io.IOException
Return the virtual size of the file.- Returns:
- The size in bytes.
- Throws:
java.io.IOException
- if there was a problem with the stream
-
exists
boolean exists()
Returns true if this file exists- Returns:
- True if exists.
-
createDirectory
IVirtualFile createDirectory(java.lang.String dirName) throws java.io.IOException
Creates a directory under this directory- Parameters:
dirName
- The name of the directory to be created- Returns:
- The new directory.
- Throws:
java.io.IOException
- if there was a problem with the stream
-
createFile
IVirtualFile createFile(java.lang.String filename) throws java.io.IOException
Create a file under this directory- Parameters:
filename
- The file name.- Returns:
- The new file.
- Throws:
java.io.IOException
- if there was a problem with the stream
-
rename
void rename(java.lang.String newFilename) throws java.io.IOException
Rename the virtual file name- Parameters:
newFilename
- The new filename this file will be renamed to- Throws:
java.io.IOException
- if there was a problem with the stream
-
move
IVirtualFile move(IVirtualFile dir) throws java.io.IOException
Move file to another directory.- Parameters:
dir
- Target directory.- Returns:
- The file
- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
move
IVirtualFile move(IVirtualFile dir, IFile.MoveOptions options) throws java.io.IOException
Move file to another directory.- Parameters:
dir
- Target directory.options
- The options- Returns:
- The file
- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
copy
IVirtualFile copy(IVirtualFile dir) throws java.io.IOException
Copy file to another directory.- Parameters:
dir
- Target directory.- Returns:
- The file
- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
copy
IVirtualFile copy(IVirtualFile dir, IFile.CopyOptions options) throws java.io.IOException
Copy file to another directory.- Parameters:
dir
- Target directory.options
- The options- Returns:
- The file
- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
copyRecursively
void copyRecursively(IVirtualFile dest) throws java.io.IOException
Copy a directory recursively- Parameters:
dest
- The destination directory- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
copyRecursively
void copyRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveCopyOptions options) throws java.io.IOException
Copy a directory recursively- Parameters:
dest
- The destination directoryoptions
- The options- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
moveRecursively
void moveRecursively(IVirtualFile dest) throws java.io.IOException
Move a directory recursively- Parameters:
dest
- The destination directory- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
moveRecursively
void moveRecursively(IVirtualFile dest, IVirtualFile.VirtualRecursiveMoveOptions options) throws java.io.IOException
Move a directory recursively- Parameters:
dest
- The destination directoryoptions
- The options- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
deleteRecursively
void deleteRecursively()
Delete all subdirectories and files.
-
deleteRecursively
void deleteRecursively(IVirtualFile.VirtualRecursiveDeleteOptions options)
Delete all subdirectories and files.- Parameters:
options
- The options
-
-