Package com.mku.fs.file
Interface IFile
-
- All Known Implementing Classes:
AndroidFile,File,HttpFile,WSFile
public interface IFileA real file. This class is used internally by the virtual disk to import, store, and export the encrypted files. Extend this to provide an interface to any file system, platform, or API ie: on disk, memory, network, or cloud.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIFile.CopyContentsOptionsDirectory move options (recursively)static classIFile.CopyOptionsFile copy optionsstatic classIFile.MoveOptionsFile move optionsstatic classIFile.RecursiveCopyOptionsDirectory copy options (recursively)static classIFile.RecursiveDeleteOptionsDirectory move options (recursively)static classIFile.RecursiveMoveOptionsDirectory move options (recursively)
-
Field Summary
Fields Modifier and Type Field Description static Function<IFile,java.lang.String>autoRenameGet an auto generated copy of the name for a file.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static java.lang.StringautoRename(java.lang.String filename)Provide an alternative file name.IFilecopy(IFile newDir)Copy this file to another directory.IFilecopy(IFile newDir, IFile.CopyOptions options)Copy this file to another directory.static booleancopyFileContents(IFile src, IFile dest)Copy contents of a file to another file.static booleancopyFileContents(IFile src, IFile dest, IFile.CopyContentsOptions options)Copy contents of a file to another file.default voidcopyRecursively(IFile destDir)Copy a directory recursivelydefault voidcopyRecursively(IFile destDir, IFile.RecursiveCopyOptions options)Copy a directory recursivelyIFilecreateDirectory(java.lang.String dirName)Create the directory with the name provided under this directory.IFilecreateFile(java.lang.String filename)Create an empty file with the provided name.booleandelete()Delete this file.default voiddeleteRecursively()Delete a directory recursivelydefault voiddeleteRecursively(IFile.RecursiveDeleteOptions options)Delete a directory recursivelybooleanexists()Check if this file exists.IFilegetChild(java.lang.String filename)Get the file/directory matching the name provided under this directory.intgetChildrenCount()Get the count of files and subdirectoriesjava.lang.StringgetDisplayPath()Get the display path of the file on disk.RandomAccessStreamgetInputStream()Get a stream for reading the file.longgetLastDateModified()Get the last modified date of the file.longgetLength()Get the length for the file.java.lang.StringgetName()Get the file nameRandomAccessStreamgetOutputStream()Get a stream for writing to the file.IFilegetParent()Get the parent directory of this file/directory.java.lang.StringgetPath()Get the original filepath of this file.booleanisDirectory()Check if this is a directory.booleanisFile()Check if this is a file.IFile[]listFiles()Get all files and directories under this directory.booleanmkdir()Create a directory with the current filepath.IFilemove(IFile newDir)Move this file to another directory.IFilemove(IFile newDir, IFile.MoveOptions options)Move this file to another directory.default voidmoveRecursively(IFile destDir)Move a directory recursivelydefault voidmoveRecursively(IFile destDir, IFile.RecursiveMoveOptions options)Move a directory recursivelybooleanrenameTo(java.lang.String newFilename)Rename file.voidreset()Reset cached properties
-
-
-
Method Detail
-
exists
boolean exists()
Check if this file exists.- Returns:
- True if file exists
-
delete
boolean delete()
Delete this file.- Returns:
- True if file deleted.
-
getInputStream
RandomAccessStream getInputStream() throws java.io.FileNotFoundException
Get a stream for reading the file.- Returns:
- The input stream
- Throws:
java.io.FileNotFoundException- Thrown if file not found
-
getOutputStream
RandomAccessStream getOutputStream() throws java.io.FileNotFoundException
Get a stream for writing to the file.- Returns:
- The output stream
- Throws:
java.io.FileNotFoundException- Thrown if file not found
-
renameTo
boolean renameTo(java.lang.String newFilename) throws java.io.FileNotFoundExceptionRename file.- Parameters:
newFilename- The new filename- Returns:
- True if success.
- Throws:
java.io.FileNotFoundException- Thrown if file not found
-
getLength
long getLength()
Get the length for the file.- Returns:
- The length.
-
getChildrenCount
int getChildrenCount()
Get the count of files and subdirectories- Returns:
- The children count
-
getLastDateModified
long getLastDateModified()
Get the last modified date of the file.- Returns:
- The last date modified in milliseconds
-
getDisplayPath
java.lang.String getDisplayPath()
Get the display path of the file on disk.- Returns:
- The display path
-
getPath
java.lang.String getPath()
Get the original filepath of this file. This might symlinks or merged folders. To get the display path usegetDisplayPath().- Returns:
- The file path
-
isFile
boolean isFile()
Check if this is a file.- Returns:
- True if this is a file
-
isDirectory
boolean isDirectory()
Check if this is a directory.- Returns:
- True if this is a directory.
-
listFiles
IFile[] listFiles()
Get all files and directories under this directory.- Returns:
- The files
-
getName
java.lang.String getName()
Get the file name- Returns:
- The file name
-
createDirectory
IFile createDirectory(java.lang.String dirName)
Create the directory with the name provided under this directory.- Parameters:
dirName- Directory name.- Returns:
- The newly created directory.
-
getParent
IFile getParent()
Get the parent directory of this file/directory.- Returns:
- The parent directory.
-
createFile
IFile createFile(java.lang.String filename) throws java.io.IOException
Create an empty file with the provided name.- Parameters:
filename- The name for the new file.- Returns:
- The newly create file.
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
move
IFile move(IFile newDir) throws java.io.IOException
Move this file to another directory.- Parameters:
newDir- The target directory.- Returns:
- The file after the move. Use this instance for any subsequent file operations.
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
move
IFile move(IFile newDir, IFile.MoveOptions options) throws java.io.IOException
Move this file to another directory.- Parameters:
newDir- The target directory.options- The options- Returns:
- The file after the move. Use this instance for any subsequent file operations.
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
copy
IFile copy(IFile newDir) throws java.io.IOException
Copy this file to another directory.- Parameters:
newDir- The target directory.- Returns:
- The file after the copy. Use this instance for any subsequent file operations.
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
copy
IFile copy(IFile newDir, IFile.CopyOptions options) throws java.io.IOException
Copy this file to another directory.- Parameters:
newDir- The target directory.options- The options- Returns:
- The file after the copy. Use this instance for any subsequent file operations.
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
getChild
IFile getChild(java.lang.String filename)
Get the file/directory matching the name provided under this directory.- Parameters:
filename- The name of the file or directory to match.- Returns:
- The file that was matched.
-
mkdir
boolean mkdir()
Create a directory with the current filepath.- Returns:
- True if directory was created
-
reset
void reset()
Reset cached properties
-
copyFileContents
static boolean copyFileContents(IFile src, IFile dest) throws java.io.IOException
Copy contents of a file to another file.- Parameters:
src- The source directorydest- The target directory- Returns:
- True if contents were copied
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
copyFileContents
static boolean copyFileContents(IFile src, IFile dest, IFile.CopyContentsOptions options) throws java.io.IOException
Copy contents of a file to another file.- Parameters:
src- The source directorydest- The target directoryoptions- The options- Returns:
- True if contents were copied
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
copyRecursively
default void copyRecursively(IFile destDir) throws java.io.IOException
Copy a directory recursively- Parameters:
destDir- The destination directory- Throws:
java.io.IOException- Thrown if there is an IO error.
-
copyRecursively
default void copyRecursively(IFile destDir, IFile.RecursiveCopyOptions options) throws java.io.IOException
Copy a directory recursively- Parameters:
destDir- The destination directoryoptions- The options- Throws:
java.io.IOException- Thrown if there is an IO error.
-
moveRecursively
default void moveRecursively(IFile destDir) throws java.io.IOException
Move a directory recursively- Parameters:
destDir- The target directory- Throws:
java.io.IOException- Thrown if there is an IO error.
-
moveRecursively
default void moveRecursively(IFile destDir, IFile.RecursiveMoveOptions options) throws java.io.IOException
Move a directory recursively- Parameters:
destDir- The target directoryoptions- The options- Throws:
java.io.IOException- Thrown if there is an IO error.
-
deleteRecursively
default void deleteRecursively()
Delete a directory recursively
-
deleteRecursively
default void deleteRecursively(IFile.RecursiveDeleteOptions options)
Delete a directory recursively- Parameters:
options- The options
-
autoRename
static java.lang.String autoRename(java.lang.String filename)
Provide an alternative file name. Use this to rename files.- Parameters:
filename- The current file name- Returns:
- The new file name
-
-