~~Title: Special File Actions~~ Three functions are provided to support "special" actions on files. [[:reference:plugins:vfs_plugins:vfs_contextverb|VFS_ContextVerb]] is called whenever the user attempts to "invoke" a file in your namespace. This may be by double-clicking on it, right-clicking and choosing Open from the context menu, or running the internal **FileType** command on it. The most common requirement of the [[:reference:plugins:vfs_plugins:vfs_contextverb|VFS_ContextVerb]] function is to be able to open or launch files from your namespace. int VFS_ContextVerb( HANDLE hVFSData, LPVFSFUNCDATA lpFuncData, LPVFSCONTEXTVERBDATA lpVerbData ) **hVFSData** is your namespace instance handle, and **lpFuncData** is currently unused. **lpVerbData** points to a **VFSCONTEXTVERBDATA** structure which contains information about the file and which action to perform on it. This structure is defined as follows: * **UINT cbSize** \\ This is set to the size of the structure and is used to preserve compatibility with older versions of the API. You should only access any values up to and including the size of the structure. * **HWND hwndParent** \\ This is the handle to the parent window that is launching this operation. You should use this handle if you need to display any dialogs or status indicators, etc. * **LPTSTR lpszVerb** \\ This points to a verb string that indicates the action you are to perform. If this value is NULL it indicates the user double-clicked on the item and you are to perform the default action. * **LPTSTR lpszPath** \\ This string provides the full pathname of the item the action is to be performed on. * **LPTSTR lpszNewPath** \\ This points to a buffer into which you can place a new filename path. If you return **VFSCVRES_CHANGE** from the [[:reference:plugins:vfs_plugins:vfs_contextverb|VFS_ContextVerb]] function, Opus will automatically re-invoke the action on the new path you provided. For example, this lets your plugin extract the specified file to a temporary local file and then have the double-click action performed on the temporary file. * **int cchNewPathMax** \\ This value specifies the size in characters of the buffer pointed to by **lpszNewPath**. * **UINT uMsg** \\ This value specifies the message code that triggered this action. This will normally be either 0 or **WM_LBUTTONDBLCLK**. * **WPARAM fwKeys** \\ This provides any qualifiers that were in effect when the action was triggered. For example, **MK_SHIFT**, **MK_CONTROL**, **MK_ALT**, **MK_LBUTTON**, etc. * **DWORD dwFlags** \\ This value provides additional flags relating to the operation. Currently the only defined flag is **DOPUSCVF_ISDIR** which indicates that the item in question is a directory rather than a file. * **int iRotateAngle** \\ This value indicates the currently displayed rotation angle of the item's thumbnail. When the user views files in thumbnails mode they are able to rotate the display of the thumbnail, and this value lets you determine the current rotation angle if it is applicable to your plugin. There are a number of different return codes defined for [[:reference:plugins:vfs_plugins:vfs_contextverb|VFS_ContextVerb]]. These are: * **VFSCVRES_FAIL** \\ This code indicates that the operation has failed. * **VFSCVRES_HANDLED** \\ This return code indicates that you have successfully handled the operation. * **VFSCVRES_DEFAULT** \\ This code indicates that you want Opus to handle the operation itself using the default action for this file type. This return code is only applicable if the path provided in **lpszPath** refers to a real, physical file. Therefore you should only use this code if you have previously returned **VFSCVRES_CHANGE** and specified a real filesystem path in **lpszNewPath**. * **VFSCVRES_EXTRACT** \\ Return this code if you want Opus to extract the specified file from your plugin using the **VFS_ExtractFile** function. Opus will extract the file to a temporary local file and then perform the default action upon it. * **VFSCVRES_CHANGE** \\ Return this code if you have placed a new file path string in the buffer pointed to by **lpszNewPath**. Opus will then invoke the **ContextVerb** function again on that new path string. Note that this may or may not involve your [[:reference:plugins:vfs_plugins:vfs_contextverb|VFS_ContextVerb]] function being called again with the new string, depending on whether the new path references your namespace or another namespace. * **VFSCVRES_CHANGEDIR** \\ Return this code if you want Opus to read a new folder as the result of the operation. You should place the path of the folder to read in the **lpszNewPath** field. Opus will execute the **Go** command on this path string. [[:reference:plugins:vfs_plugins:vfs_extractfiles|VFS_ExtractFiles]] is a function that Opus calls from time to time to extract one or more files from your plugin's namespace to a local file. For example, if you return **VFSCVRES_EXTRACT** from the [[:reference:plugins:vfs_plugins:vfs_contextverb|VFS_ContextVerb]] function, Opus will call this function to extract the file to a local temporary file. If you do not provide this function then Opus will attempt to extract the file itself using [[:reference:plugins:vfs_plugins:vfs_createfile|VFS_CreateFile]] and [[:reference:plugins:vfs_plugins:vfs_readfile|VFS_ReadFile]]. If you are able to extract files in a more efficient manner than this you should implement this function. BOOL VFS_ExtractFiles( HANDLE hVFSData, LPVFSFUNCDATA lpFuncData, LPVFSEXTRACTFILESDATA lpExtractData ) **hVFSData** is your namespace instance handle, and **lpFuncData** is currently unused. **lpExtractData** points to a **VFSEXTRACTFILESDATA** structure which contains information about the file or files to be extracted. This structure is defined as follows: * **UINT cbSize** \\ This field specifies the size of the structure and is used to maintain compatibility with older versions of the API. You should only access any values up to and including the size of the structure. * **HWND hwndParent** \\ This is the handle to the parent window that is launching this operation. You should use this handle if you need to display any dialogs or other user interaction. * **LPTSTR lpszDestPath** \\ This field points to a string containing the desired destination path for the extracted file or files. * **LPTSTR lpszFiles** \\ This field points to a double null-terminated list of strings, each one specifying a file to extract from the plugin's namespace. * **DWORD dwFlags** \\ This is a flags field and is currently unused. When this function is called in your plugin you should attempt to extract the specified file or files to the specified destination folder. If the extraction operation will take a significant time you may wish to consider displaying a progress dialog and giving the user the option of aborting the operation. If the file extraction was successful you should return **TRUE**, otherwise you should set an appropriate error code and return **FALSE**. The [[:reference:plugins:vfs_plugins:vfs_properties|VFS_Properties]] function (not to be confused with [[:reference:plugins:vfs_plugins:vfs_propget|VFS_PropGet]]) is called when the user wants to view a Properties dialog for one or more files in your namespace. If you specified the **VFSCAPABILITY_COMBINEDPROPERTIES** capability flag your [[:reference:plugins:vfs_plugins:vfs_properties|VFS_Properties]] function may be called with multiple filenames and you should display an appropriate dialog that combines the properties of these files as best you can. If you did not specify the combined properties capability flag then [[:reference:plugins:vfs_plugins:vfs_properties|VFS_Properties]] will only ever be called with a single filename. HWND VFS_Properties( HANDLE hVFSData, LPVFSFUNCDATA lpFuncData, HWND hwndParent, LPTSTR lpszFiles ) **hVFSData** is your namespace instance handle, and **lpFuncData** is currently unused. **hwndParent** is the handle to the parent window - any dialog you display should use this window as a parent and should position itself relative to this window. **lpszFiles** is a double null-terminated list of strings containing the full pathnames of the files to show Properties for. If you do not support combined properties you can treat this as a simple string. Your [[:reference:plugins:vfs_plugins:vfs_properties|VFS_Properties]] function can either be //modal// or //modeless//. Modal means that you will run a message loop to display the dialog, and destroy the dialog when the user closes it. If you are implementing this as a modal function you should simply return **TRUE** or **FALSE** from this function (cast to **HWND**). A modeless function, on the other hand, returns the handle of a dialog window. Opus then runs a standard dialog message loop, and will destroy the dialog itself when the user clicks the close button or the Ok or Cancel button (that is, in response to a **WM_CLOSE** or appropriate **WM_COMMAND** message.) The dialog you display should be as similar in appearance to the standard Windows file Properties dialog as possible, to avoid confusing the user and to create a more seamless environment for them. If your plugin does not support the displaying of a Properties dialog at all then simply do not implement this function.