~~Title: Plugin Identification~~
When Directory Opus starts up it calls the [[.exported_functions_reference:vfs_identify|VFS_Identify]] function for each installed plugin. Each plugin responds by identifying itself and providing information on its capabilities and the types of files or virtual namespaces that it can browse.
BOOL VFS_Identify(LPVFSPLUGININFO lpVFSInfo)
Directory Opus passes you the address of a **VFSPLUGININFO** structure and you must fill out the applicable members of this structure before returning. A return code of **TRUE** indicates that the plugin is active; a return of **FALSE** means that Directory Opus will not call the plugin again in this session.
The members of the **VFSPLUGININFO** structure are as follows:
* **UINT cbSize** \\ Directory Opus initializes this field to the size of the structure before passing it to your function. You must only fill in fields in the structure up to the size supplied by Directory Opus. This allows your plugin to remain compatible with future versions of Directory Opus that may support more fields in this structure as well as with older versions of Directory Opus which may support fewer fields.
* **GUID idPlugin** \\ This field must be initialized with your plugin's GUID (Globally Unique Identifier). This is used by Directory Opus to distinguish between installed VFS plugins. You can create a GUID using the Microsoft tool provided with Visual Studio and other development packages.
* **DWORD dwVersionHigh, dwVersionLow** \\ These fields can be used to indicate to Directory Opus the version number of your plugin. Opus does not use these values directly; however, they are displayed to the user in the standard About dialog for your plugin.
* **DWORD dwFlags** \\ The flags field is used to indicate the behavior of your plugin. The currently defined flags are:
* **VFSF_CANCONFIGURE** \\ This flag indicates that your plugin exports the [[.exported_functions_reference:vfs_configure|VFS_Configure]] function. Directory Opus will enable the //Configure// option in the plugin context menu and in the Plugins section of the Opus Preferences dialog when your plugin is selected. The [[.exported_functions_reference:vfs_configure|VFS_Configure]] function will be called when the user chooses to configure your plugin via either method.
* **VFSF_CANSHOWABOUT** \\ This flag indicates that your plugin exports the [[.exported_functions_reference:vfs_about|VFS_About]] function to display a custom About dialog. If not specified, Directory Opus will display a standard About dialog for your plugin using the information you provide in the other fields of this structure.
* **VFSF_MULTIPLEFORMATS** \\ This flag indicates that your plugin can handle multiple file or archive formats. The **lpszHandleExts** should be set to **%%*%%** if this flag is specified. Instead of looking for specific file extensions before invoking your plugin, Opus will call your plugin's [[.exported_functions_reference:vfs_querypath|VFS_QueryPath]] function to enquire whether you can handle a specific file or file prefix.
* **VFSF_NONREENTRANT** \\ This flag indicates that your plugin is non-reentrant. That is, that it does not support Directory Opus calling more than one exported function simultaneously from different threads. If you set this flag Opus will use semaphore locking when calling the exported functions in your plugin to ensure that only one thread is calling your plugin at any one time.
* **DWORD dwCapabilities** \\ This field indicates, via a bitmask, the //capabilities// of your VFS plugin. The capabilities flags indicate which functions your plugin provides and in some cases is used to optimize certain operations. The capabilities flags provided in this structure define the over-all capabilities of your plugin. If you are using the **VFSF_MULTIPLEFORMATS** flag then you can also provide format-specific capabilities via the [[.exported_functions_reference:vfs_getcapabilities|VFS_GetCapabilities]] function. The currently defined capabilities flags are:
* **VFSCAPABILITY_MOVEBYRENAME** \\ Indicates that your plugin is able to move files by renaming them. If this flag is specified and the user attempts to move a file from one folder to another, Opus will call your [[.exported_functions_reference:vfs_movefile|VFS_MoveFile]] function to perform the operation. If this flag is not specified, moving a file will involve creating a copy of it and then deleting the original.
* **VFSCAPABILITY_COPYINDEFINITESIZES** \\ Indicates that the file sizes reported by your plugin are not necessarily accurate. This is used when the user copies files from your plugin. If this flag is set Opus will ignore the stated size of a file and continue to read data until you return an end-of-file indicator. If this flag is not set Opus will only read the number of bytes you have reported for the size of the file.
* **VFSCAPABILITY_CANRESUMECOPIES** \\ Indicates that your plugin can resume interrupted file transfers (or file copy operations). If this flag is set and the user attempts to resume a file transfer either to or from your plugin's namespace, Opus will call your [[.exported_functions_reference:vfs_seekfile|VFS_SeekFile]] function to position the file pointer appropriately.
* **VFSCAPABILITY_TRIGGERRESUME** \\ Set this flag if you want your plugin to be the //trigger// for a resume of an interrupted copy. If you set this flag and the user attempts to copy a file to or from your namespace that already exists, Opus will give them the option of resuming the transfer. As an example of how this flag differs from **VFSCAPABILITY_CANRESUMECOPIES**, the internal FTP namespace in Opus sets both flags, whereas the standard file system namespace only sets **VFSCAPABILITY_CANRESUMECOPIES**. This means that a user copying an existing file between two file system folders will not be given the option of resuming, but a user copying from or to an FTP namespace will be asked if they wish to resume or not. The standard file system namespace supports resume but only the FTP namespace triggers the option.
* **VFSCAPABILITY_POSTCOPYREREAD** \\ If this flag is set Opus will automatically trigger a refresh of the destination Lister whenever files are copied to it or removed from it.
* **VFSCAPABILITY_CASESENSITIVE** \\ Set this flag if your plugin's file names and paths are case-sensitive.
* **VFSCAPABILITY_RANDOMSEEK** \\ Set this flag if you support random seeking within files. If you only support sequential seeking, or do not support seeking at all, do not set this flag. Opus does not generally use or require random seeking, but some viewer plugins may require the ability.
* **VFSCAPABILITY_FILEDESCRIPTIONS** \\ Set this flag if you want your plugin to be able to provide description strings for files in its namespace. Opus will call your [[.exported_functions_reference:vfs_getfiledescription|VFS_GetFileDescription]] function to retrieve descriptions for files (for example, if the user displays the Description column in a Lister). Note that the strings returned by this function are not (necessarily) user-supplied comments - they can contain any information you desire. A separate function pair ([[.exported_functions_reference:vfs_getfilecomment|VFS_GetFileComment]] / [[.exported_functions_reference:vfs_setfilecomment|VFS_SetFileComment]]) is used to implement user-editable comments.
* **VFSCAPABILITY_ALLOWMUSICCOLUMNS** \\ Set this flag if you want the music-related Lister information fields to be available from your plugin. Note that Opus does not call your plugin to provide this information - it uses its own routines to open files in your namespace and parse them for the needed information. You can use the [[.exported_functions_reference:vfs_getcustomcolumns|VFS_GetCustomColumns]] function to provide your own information columns for display in Listers.
* **VFSCAPABILITY_ALLOWIMAGECOLUMNS** \\ Similar to the **VFSCAPABILITY_ALLOWMUSICCOLUMNS** flag, this flag indicates that you want the image-related Lister information fields to be available in your plugin's namespace.
* **VFSCAPABILITY_ALLOWEXTRADATECOLUMNS** \\ This flag indicates that you want the last accessed and creation date fields to be available in your plugin's namespace. If this flag is not set the only date fields available will be for last modified date.
* **VFSCAPABILITY_LETMEDOPARENTS** \\ If this flag is set then Opus will call your [[.exported_functions_reference:vfs_getpathparentroot|VFS_GetPathParentRoot]] function whenever it needs to calculate the parent or root of a path in your plugin's namespace. If not specified, Opus will apply standard parsing rules to calculate the desired path.
* **VFSCAPABILITY_COMBINEDPROPERTIES** \\ Set this flag if your plugin is able to display a combined Properties sheet for multiple files. If this flag is set and the user requests the properties of multiple files at once in your plugin's namespace, Opus will call your [[.exported_functions_reference:vfs_properties|VFS_Properties]] function with a double-null terminated list of files to display properties for. If this flag is not set, Opus will call your [[.exported_functions_reference:vfs_properties|VFS_Properties]] function once for each selected file.
* **VFSCAPABILITY_COMPARETIMENOSECONDS** \\ Set this flag if your plugin does not report or preserve seconds in file times. If this flag is set Opus will discard or ignore the seconds of any file times it needs to compare with times provided by your plugin.
* **VFSCAPABILITY_GETBATCHFILEINFO** \\ Set this flag if your plugin is able to handle asynchronous requests for file information (which may involve opening and reading file data). If this flag is not set, Opus will launch a background thread to read all required or desired file information for all files in the folder whenever a directory is read. If this flag is not set, Opus will only request file information when needed.
* **VFSCAPABILITY_SLOW** \\ Set this flag if your plugin represents a slow device or media. This flag is passed to viewer plugins as an indication that accesses to your plugin's namespace may take longer than expected. Additionally, Opus will not attempt to determine file type by reading the contents of the file on a slow device, and may also refrain from attempting to extract some file information in some cases.
* **VFSCAPABILITY_MULTICREATEDIR** \\ Set this flag if your plugin supports the creation of multiple directories simultaneously. If set, your [[.exported_functions_reference:vfs_createdirectory|VFS_CreateDirectory]] function should be able to handle a comma-separated list of folders to create.
* **VFSCAPABILITY_ALLOWFILEHASH** \\ Set this flag if you want your plugin to allow the hashing of files within its namespace. The actual hashing is performed by Directory Opus (currently using MD5 functions) - all that is required of your plugin if this flag is set is the ability to read sequentially from files within your namespace. If access to your files is particularly slow you may wish to disable the hash functionality.
* **VFSCAPABILITY_READONLY** \\ This flag should be set if your plugin is //read-only// - that is, if you do not support the creation of, writing to or deleting of files within your plugin's namespace. The example unrar plugin sets this flag as the required support library does not support the creation of rar archives.
* **VFSCAPABILITY_CHECKAVAILONDIRCHANGE** \\ If this flag is set Opus will call your [[.exported_functions_reference:vfs_propget|VFS_PropGet]] function to retrieve the **VFSPROP_FUNCAVAILABILITY** property and update the state of any toolbar buttons whenever a new folder is read within your plugin's namespace. This allows you to selectively enable or disable file functions on a per-folder basis and have the user interface reflect this automatically.
* **LPTSTR lpszHandlePrefix** \\ This field allows you to indicate to Directory Opus a URL-style prefix that you want to use to represent your plugin's namespace. For example, the internal File Collections system uses **%%coll://%%** as a namespace prefix. If you are using the **VFSF_MULTIPLEFORMATS** flag you can leave this field empty - Opus will call your [[.exported_functions_reference:vfs_querypath|VFS_QueryPath]] function with the full path to let your plugin determine if it wishes to handle it or not. \\ \\ When Directory Opus calls your plugin, this field may point to a buffer into which you can copy your information. The size of the buffer is given by the **cchHandlePrefixMax** field. You can either use this supplied buffer or change the address of the **lpszHandlePrefix** field to point to your own buffer. You **must** check before copying into this field that the buffer pointer is valid; if set to 0 it indicates that Directory Opus does not want this information at this time.
* **LPTSTR lpszHandleExts** \\ This field allows you to indicate to Directory Opus the file name extensions that your plugin supports. This should be a semi-colon separated string of file extensions, for example **".tar;.gz"**. If you are using the **VFSF_MULTIPLEFORMATS** flag this string should be set to **%%"*"%%**, and Opus will then call your [[.exported_functions_reference:vfs_querypath|VFS_QueryPath]] function with the file extension of an unknown or unhandled file to let your plugin determine if it wishes to handle it or not. \\ \\ When Directory Opus calls your plugin, this field may point to a buffer into which you can copy your information. The size of the buffer is given by the **cchHandleExtsMax** field. You can either use this supplied buffer or change the address of the **lpszHandleExts** field to point to your own buffer. You **must** check before copying into this field that the buffer pointer is valid; if set to 0 it indicates that Directory Opus does not want this information at this time.
* **LPTSTR lpszName** \\ This field lets you specify the "name" of your plugin. Ordinarily this will be the primary file format that your plugin supports, eg **TAR**. However, this can be any string. The name is displayed to the user in the Plugin list in Preferences as well as the standard About dialog for your plugin. It is also used as the parameter for certain Opus internal commands that take a plugin name on the command line. \\ \\ When Directory Opus calls your plugin, this field may point to a buffer into which you can copy your information. The size of this buffer is given by the **cchNameMax** field. You can either use this supplied buffer or change the address of the **lpszName** field to point to your own buffer. You **must** check before copying into this field that the buffer pointer is valid; if set to 0 it indicates that Directory Opus does not want this information at this time.
* **LPTSTR lpszDescription** \\ Lets you specify a description for your plugin that is displayed to the user in the standard About dialog for your plugin. Can be any text string but should not ordinarily be more than about 50 characters in length. \\ \\ When Directory Opus calls your plugin, this field may point to a buffer into which you can copy your information. The size of this buffer is given by the **cchDescriptionMax** field. You can either use this supplied buffer or change the address of the **lpszDescription** field to point to your own buffer. You **must** check before copying into this field that the buffer pointer is valid; if set to 0 it indicates that Directory Opus does not want this information at this time.
* **LPTSTR lpszCopyright** \\ Use this field to supply a copyright notice that is displayed to the user in the standard About dialog for your plugin. \\ \\ When Directory Opus calls your plugin, this field may point to a buffer into which you can copy your information. The size of this buffer is given by the **cchCopyrightMax** field. You can either use this supplied buffer or change the address of the **lpszCopyright** field to point to your own buffer. You **must** check before copying into this field that the buffer pointer is valid; if set to 0 it indicates that Directory Opus does not want this information at this time.
* **LPTSTR lpszURL** \\ Use this field to supply a URL string that is displayed to the user in the standard About dialog for your plugin. This can be any URL, for example, the URL for the homepage on your website for your plugin. \\ \\ When Directory Opus calls your plugin, this field may point to a buffer into which you can copy your information. The size of this buffer is given by the **cchURLMax** field. You can either use this supplied buffer or change the address of the **lpszURL** field to point to your own buffer. You **must** check before copying into this field that the buffer pointer is valid; if set to 0 it indicates that Directory Opus does not want this information at this time.
* **UINT cchHandlePrefixMax, cchHandleExtsMax, cchNameMax, cchDescriptionMax, cchCopyrightMax, cchURLMax** \\ These fields specify the supplied buffer size for the relevant string fields in the structure. You must make sure you do not copy more data into the supplied buffers than is specified in these fields. The size specified is given in characters, not bytes.
* **DWORD dwOpusVerMajor, dwOpusVerMinor** \\ These fields (provided in Directory Opus 9 only) specify the current version of Directory Opus.
* **DWORD dwInitFlags** \\ Specifies flags the plugin may use to modify its initialization. Currently defined flags are:
* **VFSINITF_FIRSTTIME** \\ This flag is set the first time a new plugin is initialized by Directory Opus.
* **VFSINITF_USB** \\ This flag is set when Directory Opus is running from a USB device.
* **HICON hIconSmall, hIconLarge** \\ These fields can be used to provide a custom icon for the plugin that is displayed to the user on the Plugins page in Preferences. Note that Directory Opus will call **DestroyIcon()** on the icons provided here.