Trying to develop a FS plugin
Moderators: Hacker, petermad, Stefan2, white
Trying to develop a FS plugin
Hi there. I'm trying to develop my first FS plugin. I've already read the FS interface provided. Unfortunatly, this is my first attempt to play with the filesystem structures provided by windows os.
I want my FS structure made by strings of text. How can i do that ?
Let suppose i have 2 array of strings. I was trying to put these strings in my filesystem structure. The first array appears in first place. The second array must appears when i press enter in the first string of FS plugin.
Can anyone help me? I know this is a simple example that do nothing, but its an interisting example for who is beginning to construct an FS Plugin and don't understand these FS structures provide by windows.
Thanks in advance.
David Jorge
I want my FS structure made by strings of text. How can i do that ?
Let suppose i have 2 array of strings. I was trying to put these strings in my filesystem structure. The first array appears in first place. The second array must appears when i press enter in the first string of FS plugin.
Can anyone help me? I know this is a simple example that do nothing, but its an interisting example for who is beginning to construct an FS Plugin and don't understand these FS structures provide by windows.
Thanks in advance.
David Jorge
- ghisler(Author)
- Site Admin
- Posts: 50421
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
You need to implement FsFindFirst and FsFindNext. In FsFindFirst, check the path sent to you by Total Commander: If it is the root "\", then send the first string. allocate some structure with malloc() (or getmem in Delphi) to store the state of the search, and return the pointer to this structure as the file find handle.
Total Commander then calls FsFindNext and sends you back your handle. Check in the state what directory is enumerated, and send back the next item from the list.
I recommend that you have a look at some plugins available with source code, e.g. the sample plugin:
https://plugins.ghisler.com/fsplugins/sampleplugin.zip
This is a very simple plugin which mirrors just the local file system. Observing what it does in a debugger is a good way to learn how plugins work.
Total Commander then calls FsFindNext and sends you back your handle. Check in the state what directory is enumerated, and send back the next item from the list.
I recommend that you have a look at some plugins available with source code, e.g. the sample plugin:
https://plugins.ghisler.com/fsplugins/sampleplugin.zip
This is a very simple plugin which mirrors just the local file system. Observing what it does in a debugger is a good way to learn how plugins work.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Thank you by your answer.ghisler(Author) wrote: I recommend that you have a look at some plugins available with source code, e.g. the sample plugin:
https://plugins.ghisler.com/fsplugins/sampleplugin.zip
This is a very simple plugin which mirrors just the local file system. Observing what it does in a debugger is a good way to learn how plugins work.
I have already seen the sample plugin provided. The problem is about my poor knowledge or windows filestructure (findfirst, findnext and due to these functions being recurvive functions which are dificulty to understand).
So, if i want to assign one string to the file directory so that the string appears in the file panel, do i need to implement the FsFindNext? I know that a FsFindNext is only needed to descend in the file structure (which its not what i want).
Thanks. djorge.
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
You have to fill the structure (you reveive a pointer to it, the memory is already allocated). First fill it with 0, the only mandatory field is the filename. Just copy the appropriate name with strcopy or similar (it is a null terminated string). If you want to fill the change date, look at the type, and convert your string accordingly and again, copy the value into the structure. And so onSo, if i want to assign one string to the file directory so that the string appears in the file panel, do i need to implement the FsFindNext? I know that a FsFindNext is only needed to descend in the file structure (which its not what i want).

I switched to Linux, bye and thanks for all the fish!
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
A very minimalistic template in Delphi:
This shows one file in the panel (Test1.txt), date is what integer 0 means as date
no size, or attributes.
Code: Select all
library TCFSPluginTest;
{$DEFINE NOFORMS}
uses
fsPlugin,
SysUtils,
Classes,
Windows,
ShellApi;
{$E wfx}
{$R *.res}
var
giPluginNr: integer;
procedure FsGetDefRootName(DefRootName:pchar;maxlen:integer); stdcall;
begin
StrPCopy(DefRootName, 'FSPluginTest' );
end;
function FsInit(
PluginNr: Integer;
pProgressProc: TProgressProc;
pLogProc: TLogProc;
pRequestProc: TRequestProc )
: Integer; stdcall;
begin
giPluginNr := PluginNr;
Result := 0;
end;
function FsFindFirst(
path :pchar;
var FindData: tWIN32FINDDATA )
: thandle; stdcall;
begin
FillChar( FindData, SizeOf( FindData ), 0 );
StrPCopy( FindData.cFileName, 'Test1.txt' );
Result := 13;
end;
function FsFindNext(
Hdl: thandle;
var FindData:tWIN32FINDDATA )
: bool; stdcall;
begin
Result := False;
end;
function FsFindClose(Hdl:thandle):integer; stdcall;
begin
Result := 0;
end;
exports
FsGetDefRootName,
FsInit,
FsFindFirst,
FsFindNext,
FsFindClose;
begin
end.

I switched to Linux, bye and thanks for all the fish!
Thank you very much. I have convert your code into c++ and it worked. Now i am beginning to understand how this stuff worksSanskritFritz wrote:A This shows one file in the panel (Test1.txt), date is what integer 0 means as dateno size, or attributes.

In my next challenge i want a dialog box to appear when i press enter whenever the cursor is on top the filename. How do i do that?
Thanks in advance.
djorge
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
The problem i had when using the AfXmessageBox called was with include conflits. It seems that totalcmd is a pure win32 application and needs to have the header windows.h included which is not supported when we include MFC code.
I have created window with the fuction MessageBox(....) which is a pure win32 function.
I don't know if i am right....
Thanks djorge
I have created window with the fuction MessageBox(....) which is a pure win32 function.
I don't know if i am right....
Thanks djorge
- ghisler(Author)
- Site Admin
- Posts: 50421
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Total Commander is in fact a Delphi program, which uses its own class library different from MFC. I don't know whether it's possible to write plugins using MFC - it shouldn't be any different from writing DLLs with MFC when the calling app doesn't use MFC.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
2djorge
All you need to provide is callback functions, in an appropriate manner (__stdcall, etc.) and call some TC functions by function pointers you receive when calling FsInit. This is purely C related functionality, MFC is just a library you use.
Where did you include windows.h?
Why? The fsplugin.h header is all you need to interface with TC. What YOUR dll uses as headers, is entirelly your decision. There is no source taken from TC whatsoever.needs to have the header windows.h included
All you need to provide is callback functions, in an appropriate manner (__stdcall, etc.) and call some TC functions by function pointers you receive when calling FsInit. This is purely C related functionality, MFC is just a library you use.
Where did you include windows.h?
I switched to Linux, bye and thanks for all the fish!
2 ghisler(Author)
I have already written 3 plugins - LinkInfo, VirtualDisk and JccView - and all of them are written using MFC. And all of them work normally.
It is possibleTotal Commander is in fact a Delphi program, which uses its own class library different from MFC. I don't know whether it's possible to write plugins using MFC - it shouldn't be any different from writing DLLs with MFC when the calling app doesn't use MFC.

- ghisler(Author)
- Site Admin
- Posts: 50421
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Thanks for confirming it! Since I don't use MFC myself, it would be nice if there were at least one MFC plugin with source as an example for others...
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com