Class FileCommander

java.lang.Object
com.mku.fs.drive.utils.FileCommander
Direct Known Subclasses:
AesFileCommander

public class FileCommander extends Object
Facade class for file operations.
  • Constructor Details

    • FileCommander

      public FileCommander(FileImporter fileImporter, FileExporter fileExporter, FileSearcher fileSearcher)
      Instantiate a new file commander object.
      Parameters:
      fileImporter - The importer to use
      fileExporter - The exporter to use
      fileSearcher - The searcher to use
  • Method Details

    • getFileImporter

      public FileImporter getFileImporter()
      Get the file importer.
      Returns:
      The file importer.
    • getFileExporter

      public FileExporter getFileExporter()
      Get the file exporter.
      Returns:
      The file exporter.
    • getFileSearcher

      public FileSearcher getFileSearcher()
      Get the file searcher.
      Returns:
      The file searcher.
    • importFiles

      public IVirtualFile[] importFiles(IFile[] filesToImport, IVirtualFile importDir) throws Exception
      Import IFile(s) into the drive.
      Parameters:
      filesToImport - The files to import.
      importDir - The target directory.
      Returns:
      The imported files.
      Throws:
      Exception - Thrown if error occurs during import
    • importFiles

      public IVirtualFile[] importFiles(IFile[] filesToImport, IVirtualFile importDir, FileCommander.BatchImportOptions options) throws Exception
      Import IFile(s) into the drive.
      Parameters:
      filesToImport - The files to import.
      importDir - The target directory.
      options - The options
      Returns:
      The imported files.
      Throws:
      Exception - Thrown if error occurs during import
    • exportFiles

      public IFile[] exportFiles(IVirtualFile[] filesToExport, IFile exportDir) throws Exception
      Export IVirtualFile(s) from the drive.
      Parameters:
      filesToExport - The files to export.
      exportDir - The export target directory
      Returns:
      The exported files
      Throws:
      Exception - Thrown if error occurs during export
    • exportFiles

      public IFile[] exportFiles(IVirtualFile[] filesToExport, IFile exportDir, FileCommander.BatchExportOptions options) throws Exception
      Export IVirtualFile(s) from the drive.
      Parameters:
      filesToExport - The files to export.
      exportDir - The export target directory
      options - The options
      Returns:
      The exported files
      Throws:
      Exception - Thrown if error occurs during export
    • deleteFiles

      public void deleteFiles(IVirtualFile[] filesToDelete)
      Delete files from a drive.
      Parameters:
      filesToDelete - The files to delete.
    • deleteFiles

      public void deleteFiles(IVirtualFile[] filesToDelete, FileCommander.BatchDeleteOptions options)
      Delete files from a drive.
      Parameters:
      filesToDelete - The files to delete.
      options - The options
    • copyFiles

      public void copyFiles(IVirtualFile[] filesToCopy, IVirtualFile dir, FileCommander.BatchCopyOptions options) throws Exception
      Copy files to another directory.
      Parameters:
      filesToCopy - The array of files to copy.
      dir - The target directory.
      options - The options
      Throws:
      Exception - Thrown if error occurs during copying
    • cancel

      public void cancel()
      Cancel all jobs.
    • isFileSearcherRunning

      public boolean isFileSearcherRunning()
      Check if file search is currently running.
      Returns:
      True if search is running
    • isRunning

      public boolean isRunning()
      Check if jobs are currently running.
      Returns:
      True if a job is running
    • isFileSearcherStopped

      public boolean isFileSearcherStopped()
      Check if file search stopped.
      Returns:
      True if file search is stopped
    • stopFileSearch

      public void stopFileSearch()
      Stop the current file search.
    • search

      public IVirtualFile[] search(IVirtualFile dir, String terms)
      Search for files in a drive.
      Parameters:
      dir - The directory to start the search.
      terms - The terms to search for.
      Returns:
      An array with all the results found.
    • search

      public IVirtualFile[] search(IVirtualFile dir, String terms, FileSearcher.SearchOptions options)
      Search for files in a drive.
      Parameters:
      dir - The directory to start the search.
      terms - The terms to search for.
      options - The options
      Returns:
      An array with all the results found.
    • areJobsStopped

      public boolean areJobsStopped()
      Check if all jobs are stopped.
      Returns:
      True if jobs are stopped
    • close

      public void close()
      Close the commander and release resources.
    • renameFile

      public void renameFile(IVirtualFile ifile, String newFilename) throws IOException
      Rename an encrypted file
      Parameters:
      ifile - The file to rename
      newFilename - The new file name
      Throws:
      IOException - Thrown if there is an IO error.
    • onError

      protected boolean onError(Exception ex) throws Exception
      Handler the error. If true the commander will proceed with the next file otherwise it will stop the batch. You can override this in your implementation.
      Parameters:
      ex - The exception
      Returns:
      True if recoverable
      Throws:
      Exception - If error occurs