Package com.mku.fs.drive.utils
Class FileCommander
- java.lang.Object
-
- com.mku.fs.drive.utils.FileCommander
-
- Direct Known Subclasses:
AesFileCommander
public class FileCommander extends java.lang.Object
Facade class for file operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileCommander.BatchCopyOptions
Batch copy optionsstatic class
FileCommander.BatchDeleteOptions
Batch delete optionsstatic class
FileCommander.BatchExportOptions
Batch export optionsstatic class
FileCommander.BatchImportOptions
Batch import optionsclass
FileCommander.RealFileTaskProgress
Task progress for IFile(s).class
FileCommander.VirtualFileTaskProgress
Task progress for IVirtualFile(s).
-
Constructor Summary
Constructors Constructor Description FileCommander(FileImporter fileImporter, FileExporter fileExporter, FileSearcher fileSearcher)
Instantiate a new file commander object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areJobsStopped()
Check if all jobs are stopped.void
cancel()
Cancel all jobs.void
close()
Close the commander and release resources.void
copyFiles(IVirtualFile[] filesToCopy, IVirtualFile dir, FileCommander.BatchCopyOptions options)
Copy files to another directory.void
deleteFiles(IVirtualFile[] filesToDelete)
Delete files from a drive.void
deleteFiles(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.FileExporter
getFileExporter()
Get the file exporter.FileImporter
getFileImporter()
Get the file importer.FileSearcher
getFileSearcher()
Get the file searcher.IVirtualFile[]
importFiles(IFile[] filesToImport, IVirtualFile importDir)
Import IFile(s) into the drive.IVirtualFile[]
importFiles(IFile[] filesToImport, IVirtualFile importDir, FileCommander.BatchImportOptions options)
Import IFile(s) into the drive.boolean
isFileSearcherRunning()
Check if file search is currently running.boolean
isFileSearcherStopped()
Check if file search stopped.boolean
isRunning()
Check if jobs are currently running.void
renameFile(IVirtualFile ifile, java.lang.String newFilename)
Rename an encrypted fileIVirtualFile[]
search(IVirtualFile dir, java.lang.String terms)
Search for files in a drive.IVirtualFile[]
search(IVirtualFile dir, java.lang.String terms, FileSearcher.SearchOptions options)
Search for files in a drive.void
stopFileSearch()
Stop the current file search.
-
-
-
Constructor Detail
-
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 Detail
-
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 java.lang.Exception
Import IFile(s) into the drive.- Parameters:
filesToImport
- The files to import.importDir
- The target directory.- Returns:
- The imported files.
- Throws:
java.lang.Exception
- Thrown if error occurs during import
-
importFiles
public IVirtualFile[] importFiles(IFile[] filesToImport, IVirtualFile importDir, FileCommander.BatchImportOptions options) throws java.lang.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:
java.lang.Exception
- Thrown if error occurs during import
-
exportFiles
public IFile[] exportFiles(IVirtualFile[] filesToExport, IFile exportDir) throws java.lang.Exception
Export IVirtualFile(s) from the drive.- Parameters:
filesToExport
- The files to export.exportDir
- The export target directory- Returns:
- The exported files
- Throws:
java.lang.Exception
- Thrown if error occurs during export
-
exportFiles
public IFile[] exportFiles(IVirtualFile[] filesToExport, IFile exportDir, FileCommander.BatchExportOptions options) throws java.lang.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:
java.lang.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 java.lang.Exception
Copy files to another directory.- Parameters:
filesToCopy
- The array of files to copy.dir
- The target directory.options
- The options- Throws:
java.lang.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, java.lang.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, java.lang.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, java.lang.String newFilename) throws java.io.IOException
Rename an encrypted file- Parameters:
ifile
- The file to renamenewFilename
- The new file name- Throws:
java.io.IOException
- Thrown if there is an IO error.
-
-