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 Detail

      • autoRename

        static final Function<IFile,​java.lang.String> autoRename
        Get an auto generated copy of the name for a file.
    • 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 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

        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 directory
        dest - 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 directory
        dest - The target directory
        options - 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 directory
        options - 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 directory
        options - 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