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.
    • 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 exception
        IntegrityException - 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 exception
        IntegrityException - 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 directory
        options - 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 directory
        options - The options
        Throws:
        java.io.IOException - Thrown if there is an IO error.
      • deleteRecursively

        void deleteRecursively()
        Delete all subdirectories and files.