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.
  • Field Details

    • autoRename

      static final Function<IFile,String> autoRename
      Get an auto generated copy of the name for a file.
  • Method Details

    • 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 FileNotFoundException
      Get a stream for reading the file.
      Returns:
      The input stream
      Throws:
      FileNotFoundException - Thrown if file not found
    • getOutputStream

      RandomAccessStream getOutputStream() throws FileNotFoundException
      Get a stream for writing to the file.
      Returns:
      The output stream
      Throws:
      FileNotFoundException - Thrown if file not found
    • renameTo

      boolean renameTo(String newFilename) throws FileNotFoundException
      Rename file.
      Parameters:
      newFilename - The new filename
      Returns:
      True if success.
      Throws:
      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

      String getDisplayPath()
      Get the display path of the file on disk.
      Returns:
      The display path
    • getPath

      String getPath()
      Get the original filepath of this file. This might symlinks or merged folders. To get the display path use getDisplayPath().
      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

      String getName()
      Get the file name
      Returns:
      The file name
    • createDirectory

      IFile createDirectory(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(String filename) throws IOException
      Create an empty file with the provided name.
      Parameters:
      filename - The name for the new file.
      Returns:
      The newly create file.
      Throws:
      IOException - Thrown if there is an IO error.
    • move

      IFile move(IFile newDir) throws 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:
      IOException - Thrown if there is an IO error.
    • move

      IFile move(IFile newDir, IFile.MoveOptions options) throws 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:
      IOException - Thrown if there is an IO error.
    • copy

      IFile copy(IFile newDir) throws 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:
      IOException - Thrown if there is an IO error.
    • copy

      IFile copy(IFile newDir, IFile.CopyOptions options) throws 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:
      IOException - Thrown if there is an IO error.
    • getChild

      IFile getChild(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
    • getCredentials

      Credentials getCredentials()
      Get the credentials
      Returns:
      The credentials
    • copyFileContents

      static boolean copyFileContents(IFile src, IFile dest) throws IOException
      Copy contents of a file to another file.
      Parameters:
      src - The source directory
      dest - The target directory
      Returns:
      True if contents were copied
      Throws:
      IOException - Thrown if there is an IO error.
    • copyFileContents

      static boolean copyFileContents(IFile src, IFile dest, IFile.CopyContentsOptions options) throws IOException
      Copy contents of a file to another file.
      Parameters:
      src - The source directory
      dest - The target directory
      options - The options
      Returns:
      True if contents were copied
      Throws:
      IOException - Thrown if there is an IO error.
    • copyRecursively

      default void copyRecursively(IFile destDir) throws IOException
      Copy a directory recursively
      Parameters:
      destDir - The destination directory
      Throws:
      IOException - Thrown if there is an IO error.
    • copyRecursively

      default void copyRecursively(IFile destDir, IFile.RecursiveCopyOptions options) throws IOException
      Copy a directory recursively
      Parameters:
      destDir - The destination directory
      options - The options
      Throws:
      IOException - Thrown if there is an IO error.
    • moveRecursively

      default void moveRecursively(IFile destDir) throws IOException
      Move a directory recursively
      Parameters:
      destDir - The target directory
      Throws:
      IOException - Thrown if there is an IO error.
    • moveRecursively

      default void moveRecursively(IFile destDir, IFile.RecursiveMoveOptions options) throws IOException
      Move a directory recursively
      Parameters:
      destDir - The target directory
      options - The options
      Throws:
      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 String autoRename(String filename)
      Provide an alternative file name. Use this to rename files.
      Parameters:
      filename - The current file name
      Returns:
      The new file name