Class AbstractFileExtractorTask

  • All Implemented Interfaces:
    Direct Known Subclasses:

    public abstract class AbstractFileExtractorTask
    extends Task
    Common base class for tasks that need to extract files from a GFileSystem location.

    • Field Detail

      • rootOutputDirectory

        protected rootOutputDirectory
    • Method Detail

      • startExtract

        protected void startExtract​(GFileSystem fs,
                                    GFile srcDir,
                                    TaskMonitor monitor)
                             throws CancelledException,
        Starts the file extraction process.
        fs - the GFileSystem that holds the files
        srcDir - the starting directory to extract, if null, start at root of file system
        rootOutputDirectory - the destination directory
        monitor - TaskMonitor that will be updated with progress and checked for cancel
      • processDirectory

        protected void processDirectory​(GFile srcGFileDirectory,
                                        TaskMonitor monitor)
        Extract the contents of a directory in a GFileSystem into a local file system directory.

        The destination directory is created if not present.

        srcGFileDirectory - if null, directory is filesystem root
        destDirectory - destination / output directory
        monitor - TaskMonitor to watch and update with progress
        Throws: - if IO problem.
      • mapSourceFilenameToDest

        protected java.lang.String mapSourceFilenameToDest​(GFile srcFile)
        Maps the untrusted, potentially hostile, filename of the source file to a name that is suitable to be used to create a file on the user's local file system.

        NOTE: This base implementation converts relative directory names to spelled-out versions of that directory, eg. "." becomes "dot".

        If you wish to modify this behavior, override this method and return different mappings.

        srcFile - source file
        String name of the source file, possibly modified to be safer
        Throws: - thrown if name is not mappable and the extract process should stop
      • handleUnexpectedException

        protected boolean handleUnexpectedException​(GFile file,
                                                    java.lang.Exception e)
        Allows custom handling of exceptions that occur during file extraction.

        Return true if the exception should be ignored by the file extraction process, otherwise return false if it should be propagated up the call stack.

        file - file that was being extracted when the exception happened
        e - the exception
        true if the exception should be suppressed, false if the exception should be thrown
      • getTotalFilesExportedCount

        public int getTotalFilesExportedCount()
        Return the number of files that were exported.

        the number of files that were exported
      • getTotalDirsExportedCount

        public int getTotalDirsExportedCount()
        Return the number of directories that were exported.

        the number of directories that were exported
      • getTotalBytesExportedCount

        public long getTotalBytesExportedCount()
        Return the number of bytes that were exported.

        the number of bytes that were exported