OpenFilePlugin

Far Manager

OpenFilePlugin

The OpenFilePlugin function is called to open a plugin which emulates a file system based on a file passed to this function (an archive for example).
HANDLE WINAPI OpenFilePlugin(
  char *Name,
  const unsigned char *Data,
  int DataSize
);

Parameters

Name
Points to the full name of the file (including the path). This pointer is valid only until return, so if the plugin will process this file, it should copy this name to an internal variable.
The OpenFilePlugin function is also called when the user is going to create a new file (when Shift-F1 is pressed). In that case Name is NULL and other parameters are undefined. If a plugin does not support creating new files, it must return INVALID_HANDLE_VALUE, otherwise it must return the handle of a new plugin instance that must be ready to process GetOpenPluginInfo and PutFiles functions. If Name is NULL, the plugin needs to request Name from the user in the PutFiles function.
Data
Points to data from the beginning of the file. It can be used to detect file type. The plugin must not change this data.
DataSize
Size of the passed file data. Currently it can be from 0 to 128Kb, depending on file size, but you should be ready to process any other value.

Return value

  • If the plugin will process the passed file, the return value must be new plugin handle.
  • If this file type is not supported, the return value must be INVALID_HANDLE_VALUE.
  • If operation is interrupted by the user, the value -2 (cast to the HANDLE type) should be returned.

Remarks

  1. When <Enter> is pressed on a selected file, FAR queries all plugins that export this function. The plugins are queried in alphabetic order (sorted by the DLL name). When a plugin returns a value different from INVALID_HANDLE_VALUE, FAR stops querying other plugins.
  2. The size of data read from the file can be configured - TechInfo #63:
    [HKEY_CURRENT_USER\Software\Far\System]
    "PluginMaxReadData":REG_DWORD
    The key "System/PluginMaxReadData" of DWORD type allows to set the
    maximum size of the data read from a file after an attempt to enter
    it from the panels (Enter or Ctrl-PgDn) was made. The data read will
    be passed to plugins to determine which plugin supports a file of this
    type.
    Can be any value in the range of 0x1000 to 0x80000.
    The default value is 0x20000.