-New directories not shown in second window

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

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

NOT cofirmed - with auto-refresh enabled or disabled, it always appears.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

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:

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.
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
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

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.
I can confirm this - with WatchDirs=0.

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
JFierce7
Senior Member
Senior Member
Posts: 214
Joined: 2005-07-17, 10:47 UTC

Post by *JFierce7 »

ghisler(Author) wrote:NOT cofirmed - with auto-refresh enabled or disabled, it always appears.
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.
Furthermore, MarcinW showed a rather common way to reproduce that problem.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

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
JFierce7
Senior Member
Senior Member
Posts: 214
Joined: 2005-07-17, 10:47 UTC

Post by *JFierce7 »

ghisler(Author) wrote:then it is their problem, not mine.
I'm not sure why you don't want to understand or if it is me who shouldn't report bugs.

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.
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

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.
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
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

ghisler(Author) wrote:people have to provoke a bug like this by entering different case names
Mhmm, users may get such paths:
- 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
User avatar
Aezay
Senior Member
Senior Member
Posts: 269
Joined: 2003-02-12, 07:27 UTC
Location: Denmark
Contact:

Post by *Aezay »

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].
Of all the planets I've been to, this one is my favorite.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

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.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

It is time-consuming to make a path comparison when one path contains DOS names.
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.
GetShortPathName is not sufficient, it will only handle the last path part.
It returns also the full short path as the 2nd parameter (pointer to the last path part is returned in the 3rd parameter).


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
...
So the SameFileName function solves both problems - with name case and with short/long path conversion.

Regards
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, I prefer not to do this - it would result in many more potential errors.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

I can confirm that the problem with paths differing in case has been fixed. Thanks!
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

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.
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
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

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.
Post Reply