Package com.mku.fs.file
Interface IFile
-
- All Known Implementing Classes:
AndroidFile
,File
,HttpFile
,WSFile
public interface IFile
A 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 class
IFile.CopyContentsOptions
Directory move options (recursively)static class
IFile.CopyOptions
File copy optionsstatic class
IFile.MoveOptions
File move optionsstatic class
IFile.RecursiveCopyOptions
Directory copy options (recursively)static class
IFile.RecursiveDeleteOptions
Directory move options (recursively)static class
IFile.RecursiveMoveOptions
Directory move options (recursively)
-
Field Summary
Fields Modifier and Type Field Description static Function<IFile,java.lang.String>
autoRename
Get 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.String
autoRename(java.lang.String filename)
Provide an alternative file name.IFile
copy(IFile newDir)
Copy this file to another directory.IFile
copy(IFile newDir, IFile.CopyOptions options)
Copy this file to another directory.static boolean
copyFileContents(IFile src, IFile dest)
Copy contents of a file to another file.static boolean
copyFileContents(IFile src, IFile dest, IFile.CopyContentsOptions options)
Copy contents of a file to another file.default void
copyRecursively(IFile destDir)
Copy a directory recursivelydefault void
copyRecursively(IFile destDir, IFile.RecursiveCopyOptions options)
Copy a directory recursivelyIFile
createDirectory(java.lang.String dirName)
Create the directory with the name provided under this directory.IFile
createFile(java.lang.String filename)
Create an empty file with the provided name.boolean
delete()
Delete this file.default void
deleteRecursively()
Delete a directory recursivelydefault void
deleteRecursively(IFile.RecursiveDeleteOptions options)
Delete a directory recursivelyboolean
exists()
Check if this file exists.IFile
getChild(java.lang.String filename)
Get the file/directory matching the name provided under this directory.int
getChildrenCount()
Get the count of files and subdirectoriesjava.lang.String
getDisplayPath()
Get the display path of the file on disk.RandomAccessStream
getInputStream()
Get a stream for reading the file.long
getLastDateModified()
Get the last modified date of the file.long
getLength()
Get the length for the file.java.lang.String
getName()
Get the file nameRandomAccessStream
getOutputStream()
Get a stream for writing to the file.IFile
getParent()
Get the parent directory of this file/directory.java.lang.String
getPath()
Get the original filepath of this file.boolean
isDirectory()
Check if this is a directory.boolean
isFile()
Check if this is a file.IFile[]
listFiles()
Get all files and directories under this directory.boolean
mkdir()
Create a directory with the current filepath.IFile
move(IFile newDir)
Move this file to another directory.IFile
move(IFile newDir, IFile.MoveOptions options)
Move this file to another directory.default void
moveRecursively(IFile destDir)
Move a directory recursivelydefault void
moveRecursively(IFile destDir, IFile.RecursiveMoveOptions options)
Move a directory recursivelyboolean
renameTo(java.lang.String newFilename)
Rename file.void
reset()
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.FileNotFoundException
Rename 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
-
-