plugins:vfs_plugins:batch_operations

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:

  • UINT cbSize
    This field specifies the size of the VFSBATCHDATA structure.
  • HWND hwndParent
    This specifies the handle of the parent window, and can be used if you need to display any error dialogs or other windows while processing the batch operation.
  • HANDLE hAbortEvent
    This may be a handle to a Windows event object which is used to indicate that a batch operation should be aborted. If you wish to allow the user to abort your plugin (which is highly recommended), you should make sure that you check the event for signaled status at regular intervals. For example,
if ( hAbortEvent && WaitForSingleObject( hAbortEvent, 0 ) == WAIT_OBJECT_0 )
{
    // aborted
}
  • UINT uiOperation
    Specifies the batch operation type. Currently defined operations are:
    • VFSBATCHOP_ADD
      An add operation is analogous to a copy to your namespace - for example, adding files to an archive.
    • VFSBATCHOP_EXTRACT
      An extract operation is analogous to a copy from your namespace - eg, extracting files from an archive.
    • VFSBATCHOP_DELETE
      This is a delete operation - for example, removing files from an archive.
  • int iNumFiles
    Specifies the number of selected files and folders (note: does not include the contents of any sub-folders)
  • LPTSTR pszFiles
    Points to a double-null terminated list of file paths. For VFSBATCHOP_EXTRACT and VFSBATCHOP_DELETE, these will be files in your plugin's namespace. For VFSBATCHOP_ADD, these will be real files in the filesystem.
  • int* piResults
    This points to an array of int values which lets you provide a result code for each of the files specified via pszFiles. You should set each integer value to 0 if the file or folder was processed successfully, or an appropriate error code on failure. The size of the piResults array is specified by the iNumFiles value.
  • LPTSTR pszDestPath
    This specifies the destination path for a VFSBATCHOP_EXTRACT operation.
  • DWORD dwFlags
    Flags that indicate how the batch operation should be performed. Currently defined flags are:
BATCHF_COPY_PRESERVE_ATTRpreserve file attributes on add/extract
BATCHF_COPY_PRESERVE_DATEpreserve file timestamps on add/extract
BATCHF_COPY_PRESERVE_COMMENTSpreserve file comments on add/extract
BATCHF_COPY_PRESERVE_SECURITYpreserve file security information
BATCHF_COPY_ASK_REPLACEask before overwriting existing files
BATCHF_COPY_ASK_REPLACE_ROask before overwriting read-only files
BATCHF_COPY_RENAMEask user for new filenames (copy as)
BATCHF_COPY_DELETE_ORIGINALoperation is a 'move' - delete original files
BATCHF_DELETE_ASKask before beginning delete
BATCHF_DELETE_ASK_FILESask for each file before deleting
BATCHF_DELETE_ASK_FOLDERSask for each folder before deleting
BATCHF_DELETE_UNPROTECTautomatically unprotect files to delete
BATCHF_DELETE_ALLdelete all without prompting for each
BATCHF_DELETE_QUIETdon't prompt to begin deleting
BATCHF_DELETE_FORCEforce deletion
BATCHF_DELETE_SECUREsecure delete if possible
BATCHF_FILTERa filter is in force
BATCHF_FILTER_FOLDERSa filter is in force for folders
BATCHF_PROGRESS_SUBFOLDERSprogress 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.

  • LPVOID lpFuncData
    This provides a parameter that is used in several calls to the Plugin Support API for updating progress bars, filtering files, etc.

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:

ShowRequestDlggeneric message dialog helper function
ShowFunctionNewNameDlgdisplays a dialog allowing the user to specify a new filename
GetWildNewNameget a new filename from user-entered wildcard pattern
ShowFunctionErrorDlgdisplay an error message
ShowFunctionReplaceDlgdisplay 'replace existing file?' confirmation dialog
ShowFunctionInitialDeleteDlgdisplay initial confirmation dialog when deleting files
ShowFunctionDeleteDlgdisplay confirmation dialog when deleting a file or folder
FilterFunctionFileapply filters to files or folders
AddFunctionFileChangenotify Opus of a file change in your plugin's namespace
UpdateFunctionProgressBarupdate the progress bar for a batch mode operation
GetFunctionWindowretrieve 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.