SetDirectory

Far Manager

SetDirectory

The SetDirectory function is called to set the current directory in the file system emulated by the plugin.
int WINAPI SetDirectory(
  HANDLE hPlugin,
  const char *Dir,
  int OpMode
);

Parameters

hPlugin
Plugin handle returned by OpenPlugin or OpenFilePlugin.
Dir
Directory name. Usually contains only the name, without full path. To provide basic functionality the plugin should also process the names '..' and '\'.
For correct restoring of current directory after using "Search from the root folder" mode in the Find file dialog, the plugin should be able to process full directory name returned in the GetOpenPluginInfo function. It is not necessary when "Search from the current folder" mode is set in the Find file dialog.
OpMode
Combination of the operation mode flags. This function should be ready to process the OPM_FIND flag. If the OPM_FIND flag is set, the function is called from Find file or another directory scanning command, and the plugin must not perform any actions except changing directory and returning TRUE if successful or FALSE if it is impossible to change the directory. (The plugin should not try to close or update the panels, ask the user for confirmations, show messages and so on.)

Return value

If the function succeeds, the return value must be TRUE. If the function fails, FALSE should be returned.

Remarks

If the OPM_FIND flag is set in OpMode then:
  1. It means that the SetDirectory function is called from the Find file dialog (Alt-F7) or any other command that scans directory listings. Because if that the plugin must not perform any other actions except changing directory and returning TRUE if successful or FALSE if it is impossible to change the directory.
  2. The plugin should carefully process ".." and if changing to the parent directory is not possible it should return FALSE. Otherwise the search can enter an endless loop on panel of that plugin.