Directory Opus 9 supports batch-mode operations for VFS plugins. If you implement the batch interface via the VFS_BatchOperation function, Opus will call this function for any copy or delete operation involving your plugin, rather than using the filesystem-style functions described above.
BOOL VFS_BatchOperation( HANDLE hVFSData, LPVFSFUNCDATA lpFuncData, LPTSTR lpszPath, LPVFSBATCHDATA lpBatchData )
The hVFSData parameter is your namespace instance handle, and lpFuncData is not currently used. lpszPath specifies the current path in your namespace, and lpBatchData points to a VFSBATCHDATA structure that defines the operation parameters.
The fields of the VFSBATCHDATA structure are as follows:
if ( hAbortEvent && WaitForSingleObject( hAbortEvent, 0 ) == WAIT_OBJECT_0 ) { // aborted }
| BATCHF_COPY_PRESERVE_ATTR | preserve file attributes on add/extract |
| BATCHF_COPY_PRESERVE_DATE | preserve file timestamps on add/extract |
| BATCHF_COPY_PRESERVE_COMMENTS | preserve file comments on add/extract |
| BATCHF_COPY_PRESERVE_SECURITY | preserve file security information |
| BATCHF_COPY_ASK_REPLACE | ask before overwriting existing files |
| BATCHF_COPY_ASK_REPLACE_RO | ask before overwriting read-only files |
| BATCHF_COPY_RENAME | ask user for new filenames (copy as) |
| BATCHF_COPY_DELETE_ORIGINAL | operation is a 'move' - delete original files |
| BATCHF_DELETE_ASK | ask before beginning delete |
| BATCHF_DELETE_ASK_FILES | ask for each file before deleting |
| BATCHF_DELETE_ASK_FOLDERS | ask for each folder before deleting |
| BATCHF_DELETE_UNPROTECT | automatically unprotect files to delete |
| BATCHF_DELETE_ALL | delete all without prompting for each |
| BATCHF_DELETE_QUIET | don't prompt to begin deleting |
| BATCHF_DELETE_FORCE | force deletion |
| BATCHF_DELETE_SECURE | secure delete if possible |
| BATCHF_FILTER | a filter is in force |
| BATCHF_FILTER_FOLDERS | a filter is in force for folders |
| BATCHF_PROGRESS_SUBFOLDERS | progress bar knows about sub-folder contents |
Most of these flags correspond to the options in the Opus Preferences (Copying/Deleting) and may not be relevant to your plugin. The 'ask' flags should be respected if possible - you can display confirmation dialogs using the Plugin Support API, which also contains functions to make respecting the 'filter' flags easy as well.
When Opus calls your VFS_BatchOperation function, you should examine the VFSBATCHDATA structure to determine if this is an operation you can process in batch mode. If it isn't (for example, you may support batch extraction but not deletion), you should return VFSBATCHRES_DODEFAULT. This indicates to Opus that batch mode is not available and Opus will then proceed to handle the operation in the usual way (via calls to VFS_CreateFile, VFS_ReadFile, etc.)
If, however, you can process the requested operation, you should then proceed to do so. Basically this is a matter of performing the requested actions, and returning result codes for each file. However, it is also the responsibility of the plugin to emulate Opus as much as possible while processing a batch operation. This may include displaying confirmation dialogs or dialogs asking for new filenames, displaying error messages, applying filters to files and folders and updating the progress bar. It is not required that you perform all these steps, however the user will enjoy a more seamless experience if you do.
The Plugin Support API (documented separately) provides several functions which can make these steps much easier for you. The functions specifically involved with batch mode operations that you may wish to use are:
| ShowRequestDlg | generic message dialog helper function |
| ShowFunctionNewNameDlg | displays a dialog allowing the user to specify a new filename |
| GetWildNewName | get a new filename from user-entered wildcard pattern |
| ShowFunctionErrorDlg | display an error message |
| ShowFunctionReplaceDlg | display 'replace existing file?' confirmation dialog |
| ShowFunctionInitialDeleteDlg | display initial confirmation dialog when deleting files |
| ShowFunctionDeleteDlg | display confirmation dialog when deleting a file or folder |
| FilterFunctionFile | apply filters to files or folders |
| AddFunctionFileChange | notify Opus of a file change in your plugin's namespace |
| UpdateFunctionProgressBar | update the progress bar for a batch mode operation |
| GetFunctionWindow | retrieve window handle for a batch mode operation |
For example, if the BATCHF_FILTER flag was set in the VFSBATCHDATA structure, you would call the FilterFunctionFile function to see if a file was to be filtered out.
See the Plugin Support API documentation for full information about these helper functions.
Your VFS_BatchOperation function should return a value indicating the result of the batch operation. See the reference section for a full description of the return codes.