-New directories not shown in second window
Moderators: Hacker, petermad, Stefan2, white
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
NOT cofirmed - with auto-refresh enabled or disabled, it always appears.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
I can reproduce the behavior that JFierce7 described.
Before testing, turn off change notifications in configuration settings.
Test 1:
1) create directory: c:\test
2) when in one panel, type: cd c:\test
3) when in another panel, type: cd c:\Test - now above TC panels (in the breadcrumb bars) you can see paths with different case.
4) Now create some directory in one panel - the second panel will NOT be refreshed.
5) Refresh the second panel manually with Ctrl+R.
6) Now delete this newly created directory - both panels WILL be refreshed.
But I could get even into worse case.
Test 2:
1) create directory: c:\somelongname
2) when in one panel, type: cd c:\somelongname
3) when in another panel, type: cd c:\somelo~1 - now above TC panels (in the breadcrumb bars) you can see two different forms of the same path.
4) Now create some directory in one panel - the second panel will NOT be refreshed.
5) Refresh the second panel manually with Ctrl+R.
6) Now delete this newly created directory - both panels will NOT be refreshed.
So comparing file names case-insensitively is not enough. Names must be converted to their short form before comparison:
This code uses the AnsiCompareFileName function, which is not available in Delphi 2: "AnsiCompareFileName supports DOS file name comparison idiosyncracies in Far East locales (Zenkaku). In non-MBCS locales on Windows, AnsiCompareFileName is identical to AnsiCompareText (case insensitive). On Linux, AnsiCompareFileName is identical to AnsiCompareStr (case sensitive)."
TC collects file/directory names when using FindFirstFile(Ex)/FindNextFile APIs, so for comparison purposes TC should use both long forms or both short forms - not directly the names entered by the user, these should be normalized by calling GetShortPathName API, as in the example above.
Regards
Before testing, turn off change notifications in configuration settings.
Test 1:
1) create directory: c:\test
2) when in one panel, type: cd c:\test
3) when in another panel, type: cd c:\Test - now above TC panels (in the breadcrumb bars) you can see paths with different case.
4) Now create some directory in one panel - the second panel will NOT be refreshed.
5) Refresh the second panel manually with Ctrl+R.
6) Now delete this newly created directory - both panels WILL be refreshed.
But I could get even into worse case.
Test 2:
1) create directory: c:\somelongname
2) when in one panel, type: cd c:\somelongname
3) when in another panel, type: cd c:\somelo~1 - now above TC panels (in the breadcrumb bars) you can see two different forms of the same path.
4) Now create some directory in one panel - the second panel will NOT be refreshed.
5) Refresh the second panel manually with Ctrl+R.
6) Now delete this newly created directory - both panels will NOT be refreshed.
So comparing file names case-insensitively is not enough. Names must be converted to their short form before comparison:
Code: Select all
program Test;
uses
Windows, SysUtils;
function SameFileName(FileName1 : string; FileName2 : string) : Boolean;
procedure ConvertToShortName(var FileName : string);
var
Buffer : string;
Len : Cardinal;
begin
{GetShortPathName uses the current directory if FileName doesn't contain a full path}
{"It is possible to have access to a file or directory but not have access to some of
the parent directories of that file or directory. As a result, GetShortPathName may
fail when it is unable to query the parent directory of a path component to determine
the short name for that component."}
SetLength(Buffer,Length(FileName));
Len:=GetShortPathName(PChar(FileName),PChar(Buffer),Length(Buffer));
if Len = 0 then
Exit; {Most probably the file/directory doesn't exist}
if Len <= Cardinal(Length(Buffer)) then
SetString(FileName,PChar(Buffer),Len)
else {"The short form can be longer than the specified path"}
begin
SetLength(Buffer,Len);
Len:=GetShortPathName(PChar(FileName),PChar(Buffer),Length(Buffer));
if Len <= Cardinal(Length(Buffer)) then
SetString(FileName,PChar(Buffer),Len);
end;
end;
begin
ConvertToShortName(FileName1);
ConvertToShortName(FileName2);
Result:=AnsiCompareFileName(FileName1,FileName2) = 0;
end;
begin
if SameFileName('c:\somelongname','c:\somelo~1') then
MessageBox(0,'Same file/directory','Test',MB_ICONINFORMATION)
else
MessageBox(0,'Different files/directories','Test',MB_ICONSTOP);
end.
TC collects file/directory names when using FindFirstFile(Ex)/FindNextFile APIs, so for comparison purposes TC should use both long forms or both short forms - not directly the names entered by the user, these should be normalized by calling GetShortPathName API, as in the example above.
Regards
I can confirm this - with WatchDirs=0.Test 1:
1) create directory: c:\test
2) when in one panel, type: cd c:\test
3) when in another panel, type: cd c:\Test - now above TC panels (in the breadcrumb bars) you can see paths with different case.
4) Now create some directory in one panel - the second panel will NOT be refreshed.
5) Refresh the second panel manually with Ctrl+R.
6) Now delete this newly created directory - both panels WILL be refreshed.
But I could get even into worse case.
Test 2:
1) create directory: c:\somelongname
2) when in one panel, type: cd c:\somelongname
3) when in another panel, type: cd c:\somelo~1 - now above TC panels (in the breadcrumb bars) you can see two different forms of the same path.
4) Now create some directory in one panel - the second panel will NOT be refreshed.
5) Refresh the second panel manually with Ctrl+R.
6) Now delete this newly created directory - both panels will NOT be refreshed.
With WatchDirs=1 or higher the new directory does turn up at creation (and dissapear on delete) with a delay of about one second in the opposite window. Testet on TC 8.51b1 under Windows XP (32bit TC) and Windows 8.1 (64bit TC).
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Have you tried after editing history like I described? Of course, this is only a method to create a situation in which the problem occurs. How this situation had arised is another topic.ghisler(Author) wrote:NOT cofirmed - with auto-refresh enabled or disabled, it always appears.
Furthermore, MarcinW showed a rather common way to reproduce that problem.
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Sorry, but if people have to provoke a bug like this by entering different case names, then it is their problem, not mine.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
I'm not sure why you don't want to understand or if it is me who shouldn't report bugs.ghisler(Author) wrote:then it is their problem, not mine.
As I wrote before - I don't know how this situation arised. Somehow I have differently (as regards case) written path names of the same path in my history. How this happened IS your problem since I did NOT do anything unusual. I cannot tell WHAT I did, I only can describe symptoms and what I did do try to diagnose the problem.
It's easy to tell: "cannot reproduce", but I showed you a way to do that: reproduce the situation that I have.
Also, there must be a difference between creating and deleting directories, so it cannot be intentional how TC behaves for creating directories.
2ghisler(Author)
I am using DrivesShowUpcase=0, but still sometimes a capital drive letters turns up in the history - I haven't found out when and why.
But since this can happen by itself, it is fair to expect TC to check whether a panel should be updated, when changes are made to the same directory in the other panel, regardles of dirname case or longname/DOS3.8 name differencies in the two panels.
I am using DrivesShowUpcase=0, but still sometimes a capital drive letters turns up in the history - I haven't found out when and why.
But since this can happen by itself, it is fair to expect TC to check whether a panel should be updated, when changes are made to the same directory in the other panel, regardles of dirname case or longname/DOS3.8 name differencies in the two panels.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Mhmm, users may get such paths:ghisler(Author) wrote:people have to provoke a bug like this by entering different case names
- by copying from some .bat files,
- by copying from the console window, after using "dir" command, in particular "dir /X" (8.3 filenames) or "dir /L" (lowercase),
- by copying from the console window, after using "set path" command,
- by copying from the console window, after using "set temp" command,
- after using "cd %appdata%" command in the TC command line,
- etc.
So advanced users will get into this problem earlier or later.
Probably the simplest solution would be to convert all paths entered by the user to the long form (with the FindFirstFile(Ex) or GetShortPathName APIs), so both panels would have same strings for same directories in the breadcrumb bars (and in internal TC data structures).
Regards
Just noticed another bug while testing the example MarcinW gave.
If you delete a subdir in one panel, and that subdir still remains in the other, a minor issue occurs if you try to delete the now non-existing directory.
TC will now give a warning saying: "The directory <dir> is not empty!\nDo you want to delete it with all its files and subdirectories?".
The same error happens if you try to delete an empty subdir, while the other panel has "Quick View Panel" mode enabled [Ctrl+Q].
If you delete a subdir in one panel, and that subdir still remains in the other, a minor issue occurs if you try to delete the now non-existing directory.
TC will now give a warning saying: "The directory <dir> is not empty!\nDo you want to delete it with all its files and subdirectories?".
The same error happens if you try to delete an empty subdir, while the other panel has "Quick View Panel" mode enabled [Ctrl+Q].
Of all the planets I've been to, this one is my favorite.
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
My comment about provoking the bug is to the user who wrote about the DOS names. It is time-consuming to make a path comparison when one path contains DOS names. GetShortPathName is not sufficient, it will only handle the last path part. Therefore I will not support this, sorry.
I will do a refresh when the paths differ in upper-/lowercase, though.
I will do a refresh when the paths differ in upper-/lowercase, though.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
It's true, however in this case we need to perform this operation only once - after the user enters the path manually. And only for this path, not for all paths that we can see in the panels.It is time-consuming to make a path comparison when one path contains DOS names.
It returns also the full short path as the 2nd parameter (pointer to the last path part is returned in the 3rd parameter).GetShortPathName is not sufficient, it will only handle the last path part.
I just tested the code form the example above and it seems to work properly, even with old Windows 95:
Code: Select all
if SameFileName('c:\Docume~1\Defaul~1','c:\Documents and Settings\Default User') then
...
Regards
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Sorry, I prefer not to do this - it would result in many more potential errors.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
I can confirm that paths with differing case are now updated synchronnously when shown in the 2 panels in TC 8.51b2 
That also seems to apply to creating new directories when long name is used in one panel and DOS name is used in the other - but it does NOT apply to deleting directories in the same 2 panels.

That also seems to apply to creating new directories when long name is used in one panel and DOS name is used in the other - but it does NOT apply to deleting directories in the same 2 panels.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Wow! I haven't even checked this, because this thread has been moved to "will not be changed".
But I can confirm, that now, when one panel shows the short path and the other shows the long path, creating, renaming and copying (to the same panel with Shift+F5) causes refreshing the other panel - when operating both on files and on folders. So it's almost fully fixed - currently only deleting files or folder doesn't refresh the other panel.
BTW, just another idea: what about normalizing the name not immediately when entered by the user, but when scheduling directory change notifications from the system? This shouldn't introduce any potential bugs.
But I can confirm, that now, when one panel shows the short path and the other shows the long path, creating, renaming and copying (to the same panel with Shift+F5) causes refreshing the other panel - when operating both on files and on folders. So it's almost fully fixed - currently only deleting files or folder doesn't refresh the other panel.
BTW, just another idea: what about normalizing the name not immediately when entered by the user, but when scheduling directory change notifications from the system? This shouldn't introduce any potential bugs.