Packer plugin for opening Unix mailbox files

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Juergen
Power Member
Power Member
Posts: 517
Joined: 2003-05-02, 18:19 UTC
Location: Berlin (Germany)
Contact:

Packer plugin for opening Unix mailbox files

Post by *Juergen »

Hi all,

I'm writing a packer plugin for opening Unix mailbox files (read-only).
After reading 'WCX Writer's Reference.hlp' (Ver. 2.1), I have some questions:

a) SetChangeVolProc() and SetProcessDataProc():
Are these procedures mandatory or not?
In the contents of 'WCX Writer's Reference.hlp' they are listed in the category 'optional', but in the chapter 'Overview' it reads:
<quote>
The minimum functions needed for a read-only plugin are:
OpenArchive ...
ReadHeader ...
ProcessFile ...
CloseArchive ...
SetChangeVolProc ...
SetProcessDataProc ...
<unquote>

b) In the chapter 'ProcessFile', it reads:
<quote>
Either DestName contains the full path and file name and DestPath is NULL, or DestName contains only the file name and DestPath the file path.
<unquote>

So I think I'll write something like this:
---------------------------------------------------
if lpszDestPath != 0 then
DestName = DestPath & "\" & DestName
end if
---------------------------------------------------

What about putting the backslash between 'DestPath' and 'DestName'? Is it required here, or does 'DestPath' always have a trailing backslash, or must my plugin check each time, whether or not 'DestPath' has a trailing backslash?

TIA, and best regards,
Juergen
My add-ons and plugins for TC: NiftyLink, mbox, Sequences
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

a) Yes, SetChangeVolProc() and SetProcessDataProc() are needed. You can implement them as empty functions, though, if you don't want to implement the callback functions.

b) To be on the safe side, you should always check whether there is a trailing backslash or not. Total Commander doesn't use the DestPath, but other programs may use the plugins too, and could use it.

I'm using the following function in my own code. It only appends a backslash if there isn't any yet.

LPTSTR strlcatbackslash(char* thedir,int maxlen)
{
if (thedir[0] && strlen(thedir)<(DWORD)maxlen)
if (thedir[strlen(thedir)-1]!='\\')
strcat(thedir,"\\");
return thedir;
}

Call it like this:
strlcatbackslash(thedir,sizeof(thedir)-1);
Author of Total Commander
https://www.ghisler.com
Post Reply