FsFindFirst
FsFindFirst is called to retrieve the first file in a directory of the plugin's file system.
 
Declaration:
 
HANDLE __stdcall FsFindFirst(char* Path, WIN32_FIND_DATA *FindData);
 
Description of parameters:
 
Path Full path to the directory for which the directory listing has to be retrieved. Important: no wildcards are passed to the plugin! All separators will be backslashes, so you will need to convert them to forward slashes if your file system uses them!
As root, a single backslash is passed to the plugin. The root items appear in the plugin base directory retrieved by FsGetDefRootName at installation time. This default root name is NOT part of the path passed to the plugin!
All subdirs are built from the directory names the plugin returns through FsFindFirst and FsFindNext, separated by single backslashes, e.g.
\Some server\c:\subdir
 
FindData A standard WIN32_FIND_DATA struct as defined in the Windows SDK, which contains the file or directory details. Use the dwFileAttributes field set to FILE_ATTRIBUTE_DIRECTORY to distinguish files from directories. On Unix systems, you can | (or) the dwFileAttributes field with 0x80000000 and set the dwReserved0 parameter to the Unix file mode (permissions).
 
Return value:
 
Return INVALID_HANDLE_VALUE (==-1, not zero!) if an error occurs, or a number of your choice if not. It is recommended to pass a pointer to an internal structure as this handle, which stores the current state of the search. This will allow recursive directory searches needed for copying whole trees. This handle will be passed to FsFindNext() by the calling program.
 
When an error occurs, call SetLastError() to set the reason of the error. Total Commander checks for the following two errors:
1. ERROR_NO_MORE_FILES: The directory exists, but it's empty (Totalcmd can open it, e.g. to copy files to it)
2. Any other error: The directory does not exist, and Total Commander will not try to open it.
 
Important notes:
 
1. FsFindFirst may be called directly with a subdirectory of the plugin! You cannot rely on it being called with the root \ after it is loaded. Reason: Users may have saved a subdirectory to the plugin in the Ctrl+D directory hotlist in a previous session with the plugin.
 
2. "Path" can be up to 259 (MAX_PATH-1) characters long when FsFindFirstW isn't implemented, and up to 1023 characters when FsFindFirstW is implemented (also in the ANSI version of the function)! This doesn't include the final 0 character.
 
See also: FsFindNext, FsFindClose