Package com.mku.fs.drive.utils
Class FileCommander
java.lang.Object
com.mku.fs.drive.utils.FileCommander
- Direct Known Subclasses:
AesFileCommander
Facade class for file operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBatch copy optionsstatic classBatch delete optionsstatic classBatch export optionsstatic classBatch import optionsclassTask progress for IFile(s).classTask progress for IVirtualFile(s). -
Constructor Summary
ConstructorsConstructorDescriptionFileCommander(FileImporter fileImporter, FileExporter fileExporter, FileSearcher fileSearcher) Instantiate a new file commander object. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if all jobs are stopped.voidcancel()Cancel all jobs.voidclose()Close the commander and release resources.voidcopyFiles(IVirtualFile[] filesToCopy, IVirtualFile dir, FileCommander.BatchCopyOptions options) Copy files to another directory.voiddeleteFiles(IVirtualFile[] filesToDelete) Delete files from a drive.voiddeleteFiles(IVirtualFile[] filesToDelete, FileCommander.BatchDeleteOptions options) Delete files from a drive.IFile[]exportFiles(IVirtualFile[] filesToExport, IFile exportDir) Export IVirtualFile(s) from the drive.IFile[]exportFiles(IVirtualFile[] filesToExport, IFile exportDir, FileCommander.BatchExportOptions options) Export IVirtualFile(s) from the drive.Get the file exporter.Get the file importer.Get the file searcher.importFiles(IFile[] filesToImport, IVirtualFile importDir) Import IFile(s) into the drive.importFiles(IFile[] filesToImport, IVirtualFile importDir, FileCommander.BatchImportOptions options) Import IFile(s) into the drive.booleanCheck if file search is currently running.booleanCheck if file search stopped.booleanCheck if jobs are currently running.protected booleanHandler the error.voidrenameFile(IVirtualFile ifile, String newFilename) Rename an encrypted filesearch(IVirtualFile dir, String terms) Search for files in a drive.search(IVirtualFile dir, String terms, FileSearcher.SearchOptions options) Search for files in a drive.voidStop the current file search.
-
Constructor Details
-
FileCommander
public FileCommander(FileImporter fileImporter, FileExporter fileExporter, FileSearcher fileSearcher) Instantiate a new file commander object.- Parameters:
fileImporter- The importer to usefileExporter- The exporter to usefileSearcher- The searcher to use
-
-
Method Details
-
getFileImporter
Get the file importer.- Returns:
- The file importer.
-
getFileExporter
Get the file exporter.- Returns:
- The file exporter.
-
getFileSearcher
Get the file searcher.- Returns:
- The file searcher.
-
importFiles
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
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 directoryoptions- The options- Returns:
- The exported files
- Throws:
Exception- Thrown if error occurs during export
-
deleteFiles
Delete files from a drive.- Parameters:
filesToDelete- The files to delete.
-
deleteFiles
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
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
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
Rename an encrypted file- Parameters:
ifile- The file to renamenewFilename- The new file name- Throws:
IOException- Thrown if there is an IO error.
-
onError
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
-