Incorrect warning when deleting dir

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

Incorrect warning when deleting dir

Post by *MarcinW »

There is an incorrect warning sometimes - steps to reproduce (tested with Win2k and WinXP):

1) enable config option: Operation/Refresh -> Refresh when files are created, deleted and renamed (WatchDirs=1 or any odd)
2) create empty dir c:\test
3) enter into c:\test
4) open second instance of TCMD
5) using second instance, try to delete c:\test
6) c:\test is being deleted now (we can see this in case of switching to the first instance of TCMD)
7) warning appears (but shouldn't): "The directory c:\test is not empty! Do you want to delete it with all its files and subdirectories?"
8) there is no difference what button we press in this dialog, because directory has already been deleted
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, you get this also when the directory is the current directory in some other program. TC has no possibility to distinguish these two cases, sorry.
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've checked (with a debugger), that TCMD calls RemoveDirectoryA/W, which returns True (that means, that the directory has been deleted). So before displaying message "The directory c:\test is not empty!", you can probably easily check if the directory still exists (e.g. by using DirectoryExists Delphi function). If not - there is no need to display any dialog. Regards!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TCMD calls RemoveDirectoryA/W, which returns True
Strange, does the directory disappear when you close the other program then?
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 »

There is a difference between TCMD and other programs:

a) when my test program sets its current directory to C:\TEST (which is empty),
TCMD can't delete this directory - we get two warnings:
"The directory C:\TEST is not empty!" and then:
"The directory C:\TEST could not be deleted!" (and directory C:\TEST still exists)

b) when TCMD enters into C:\TEST (which is empty), another instance of
TCMD __can__ delete this directory - RemoveDirectoryA/W returns True
and then we get only one warning:
"The directory C:\TEST is not empty!" (but directory is already deleted)

So - because we can delete C:\TEST - TCMD probably doesn't set its current
directory to C:\TEST when we get into C:\TEST. So there must be some strange
reason for displaying "The directory C:\TEST is not empty!" __after__ deleting it.
umbra
Power Member
Power Member
Posts: 876
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

Hi, I could finally reproduce it. MarcinW forgot to mention that you have to delete that folder directly using Shift-F8 - if you delete it just to the Recycle bin, there is no error.
Windows 10 Pro x64, Windows 11 Pro x64
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Yes - my mistake.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, I will keep it as it is now, at least for the moment.
Author of Total Commander
https://www.ghisler.com
Post Reply