RedirectSection to NUL: safe?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

RedirectSection to NUL: safe?

Post by *StatusQuo »

Inspired by this thread:
An idea to completely avoid saving some INI sections (like history etc.) would be to redirect the unwanted sections to device NUL:

Code: Select all

[SearchName]
RedirectSection=NUL
[SearchIn]
RedirectSection=NUL
[SearchText]
RedirectSection=NUL
This seems to work (the sections are not stored) - but is it safe? Or will it lead to problems when TC tries to write to these sections?


I tried using NUL for the complete INI via command line (TOTALCMD.EXE /i=NUL), here TC does not recognize the reserved device name:
In Help / About "C:\WINDOWS\NUL" is shown as the current used INI file. Fortunately this file wasn't created here...
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

There are no problems to expect if TC cannot write to the ini. If you run TC with an ini-location where you have no write access at all TC simply uses the default settings.

You could not create a file named 'NUL' because it's a reserved name. Thus your solution with "TOTALCMD.EXE /i=NUL" will work as well. But you may should add /f=NUL to redirect the writing to the ftp-ini file.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Well, TC passes these names to WritePrivateProfileString, so it depends on Windows what will happen then. It's probably better to redirect them to a file which is regularly deleted, e.g. via a scheduled timer.
Author of Total Commander
https://www.ghisler.com
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

Thanks a lot for your answers.

I'll probably try using %COMMANDER_PATH% and/or %TEMP% to store these sections in a normal way, and experiment with NUL-redirects in TC only on my private test systems at first (imagine the mess, if the function manages to create a file with that name)...
If you omit the path in lpFileName, WritePrivateProfileString searches the Windows directory.
So I assume, using NUL with this function is impossible (always the WinDir is added to the string).


Meanwhile I found an even more brutal way, probably with less risk - at least it should be more difficult to accidentally create a file with this name, I guess :twisted: :

Code: Select all

totalcmd.exe /I=:\ /F=:\
[SearchName]
RedirectSection=:\
:arrow: Feature suggestion, if it's not too much effort: Maybe the name "NUL" could be detected and the function in TC could return without executing WritePrivateProfileString (return value 1 like the original) to take away the danger? This should be enough to emulate the use of the real NUL device, I think.
What do you think, worth a try?
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
Axel
Junior Member
Junior Member
Posts: 40
Joined: 2004-03-03, 12:29 UTC

Post by *Axel »

I'm not sure if this info is documented, but I couldn't find it anywhere.

By experimenting I ended up in using

Code: Select all

RedirectSection=>Nul
to completely avoid saving INI sections.

Example:

Code: Select all

[SearchName] 
RedirectSection=>Nul
Have fun,
Axel
Post Reply