Class FileImporter

java.lang.Object
com.mku.fs.drive.utils.FileImporter
Direct Known Subclasses:
AesFileImporter

public abstract class FileImporter extends Object
Import IFile(s) into a VirtualDrive.
  • Constructor Details

    • FileImporter

      public FileImporter()
  • Method Details

    • onPrepare

      protected abstract void onPrepare(IVirtualFile targetFile, boolean integrity) throws IOException
      Runs before import
      Parameters:
      targetFile - The target file imported
      integrity - If integrity verification is enabled
      Throws:
      IOException - If there is a problem with the file preparation.
    • getMinimumPartSize

      protected abstract long getMinimumPartSize(IVirtualFile file) throws IOException
      Get the minimum part of file that can be imported in parallel.
      Parameters:
      file - The file
      Returns:
      The number of bytes
      Throws:
      IOException - If there was a problem calculating the size.
    • initialize

      public void initialize(int bufferSize, int threads)
      Constructs a file importer that can be used to import files into the drive
      Parameters:
      bufferSize - Buffer size to be used when encrypting files. If using integrity this value has to be a multiple of the Chunk size. If not using integrity it should be a multiple of the AES block size for better performance
      threads - The threads to use for import
    • stop

      public void stop()
      Stops all current importing tasks
    • isRunning

      public boolean isRunning()
      Check if importer is currently running a job.
      Returns:
      True if running
    • importFile

      public IVirtualFile importFile(IFile fileToImport, IVirtualFile dir) throws Exception
      Imports a real file into the drive.
      Parameters:
      fileToImport - The source file that will be imported in into the drive.
      dir - The target directory in the drive that the file will be imported
      Returns:
      The imported file
      Throws:
      Exception - Thrown if error occurs during import
    • importFile

      public IVirtualFile importFile(IFile fileToImport, IVirtualFile dir, FileImporter.FileImportOptions options) throws Exception
      Imports a real file into the drive.
      Parameters:
      fileToImport - The source file that will be imported in into the drive.
      dir - The target directory in the drive that the file will be imported
      options - The options
      Returns:
      The imported file
      Throws:
      Exception - Thrown if error occurs during import
    • close

      public void close()
      Stops the current import