plugins:vfs_plugins:indicating_success_or_failure

Many functions in the VFS Plugin API are defined as type BOOL. Generally, this means they simply return TRUE (1) on success, or FALSE (0) on failure.

If a function fails for any reason, it should return FALSE, and indicate the reason for failure via the VFS_GetLastError function. Similar to the Windows GetLastError function, VFS_GetLastError is called by Directory Opus to retrieve the reason for the last error that occurred in the plugin namespace.

The error code that you return can be any of the standard Windows error codes (eg; ERROR_FILE_NOT_FOUND), or it can be one of a number of defined Opus-specific error codes. The following is a list of the currently defined codes and the error message shown to the user when they occur. Generally you should use one of the standard Windows error codes to indicate the reason for failure. Many (most) of the Opus-only error codes are specific to internal Opus functionality and do not have much relevance to VFS plugins, however they are presented here for completeness.

VFSERR_COPY_INTO_ITSELFYou can't copy or move a folder into itself.
VFSERR_NOT_SUPPORTEDThe operation is not supported by this VFS.
VFSERR_MOVE_INTO_SAMEDIRSource and destination must be different to move files.
VFSERR_DIR_ALREADY_EXISTSCannot create a folder when that folder already exists.
VFSERR_FILE_IS_DIRFile is really a folder.
VFSERR_BADLINKLink does not point to a valid file.
VFSERR_NOTEXPORTFILEFile is not a valid exported Preferences file.
VFSERR_NORECYCLEBINObject can not be placed in the recycle bin and will be permanently deleted.
VFSERR_RECYCLETOOBIGObject is too large to be placed in the recycle bin and will be permanently deleted.
VFSERR_NOPRINTHANDLERFile does not have a registered Print handler.
VFSERR_BADZIPFILEZip Compressed File is invalid or damaged.
VFSERR_GENERALERRMSGGeneral error.
VFSERR_WRITEPROTECTEDThe disk is write protected.
VFSERR_WRITEPROTECTEDZIPThe Zip Compressed File is write protected.
VFSERR_ZIPISDIRA folder already exists by that name.
VFSERR_CANTRENAMEFOLDERSFolders cannot be renamed within ZIP files.
VFSERR_SHARINGVIOLATIONThe file that you are trying to copy is in use by another process.
VFSERR_ALREADYINCOLLThe item is already in the collection.
VFSERR_CANTCOPYTOCOLLROOTFiles can not be added to the File Collections root folder.
VFSERR_NOMOVETOCOLLECTIONFiles can not be moved into a collection.
VFSERR_NOJOINTOCOLLECTIONFiles can not be joined into a collection.
VFSERR_NODROPDATATOCOLLECTIONData-only files can not be added to a collection.
VFSERR_NOCOLLINCOLLCollections can not be added to other collections.
VFSERR_FEATURENOTENABLEDThe feature is not enabled.
VFSERR_UNKNOWNERRORAn unknown error occurred.
VFSERR_CANTCOPYFILEOVERITSELFYou can't copy a file over itself.
VFSERR_CANTCHANGEZIPCASELimitations of the zip file format mean you can't change the case of a filename within a zip file.
VFSERR_NOT_EXTRACTABLEThe file is not extractable.

Of these errors codes, VFSERR_NOT_SUPPORTED is the most useful to you. You should return this error code whenever your functions do not support some aspect of the API. For example, if you support forwards seeking in files but not random seeking, you should return this error when Opus asks you to seek randomly, and success otherwise.