Strange things of internal commands md, rd

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Strange things of internal commands md, rd

Post by *MVV »

Most TC commands cannot handle special paths, e.g. with a dot at the end of dir name. However it seems that internal commands md and rd can. However there is some inconsistency that I can't understand.

This command reports error:

Code: Select all

md ...
This is logical because special prefix \\?\ is required for creation of such name.
But this one works fine:

Code: Select all

md ...\...
I can't understand why it works: if TC uses prefix, first one should work too. otherwise both shouldn't work.

Created folder can't be entered or deleted by TC directly. Let's now remove it.

This commands silently does nothing:

Code: Select all

rd ...
Perhaps it is an expected behaviour if TC doesn't use any prefix. However this one doesn't produce any error message like md does.
Surprisingly this one works:

Code: Select all

rd ...\
I can't explain why ... and ...\ are parsed differently by TC because these both point to the very same location. E.g. both rd xxx and rd xxx\ works in case of normal folder names.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50550
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, they are parsed differently when you have a backslash in the name. When you don't, TC converts the name to valid Windows names to prevent the user from accidentally creating invalid names. Currently there are no plans to change this behaviour.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Well, I just discovered that even functions CreateDirectory and RemoveDirectory allow creating and removing such crazy directories if path ends with a slash. So TC works like OS in such case.
However such paths can make some people crazy, and I would prevent them by passing paths w/o trailing slashes to API to prevent such strange things.
Post Reply