TC7.03 No confirmation before overwriting hidden/system file

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

Moderators: white, Hacker, petermad, Stefan2

User avatar
petermad
Power Member
Power Member
Posts: 14914
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

That's odd. I have the same settings.

I have just retestet with a fresh ini-file (only change is enabeling showing hidden/system files of course) - still the same result as above.

I have also tried it doing the copying in the background - no difference.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I have checked it in my code now. It seems to be a "feature" of both the CopyFileEx and the CreateFile functions.

CopyFileEx:
Here TC just tries to copy the file with flag "do not overwrite if target exists". If this fails, TC shows normal overwrite dialog. If the user clicks "Overwrite", TC tries to call CopyFileEx again with flag "allow overwrite". Only if this fails too, TC checks the file attributes and asks whether the file with this attribute should really be overwritten. It seems that CopyFileEx always denies to overwrite read only files, but only denies to overwrite hidden files with files which do not have the hidden attribute, and similar with system files.

CreateFile:
When the user confirms the overwriting, TC calls CreateFile with the attribute parameter set to the attribute of the source file. Apparently the same happens here as with CopyFileEx, so I assume that Microsoft does the same in CopyFileEx when calling CreateFile.

I think that what CopyFileEx does is quite reasonable and useful: When you overwrite hidden/system files with other hidden/system files, it's highly probable that this is intentional, e.g. for gid files or descript.ion. On the other hand, if you try to overwrite them with "normal" files, this is probably not intentional and will be stopped.

Therefore I think that it's a good idea to leave it as it is now, and document the behaviour. Maybe I can make a special switch in TC 7.5 where the user could enforce a confirmation for all cases...
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

I would prefer a consistent behavior that doesn't depend on the copy method.
User avatar
petermad
Power Member
Power Member
Posts: 14914
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Apparently the same happens here as with CopyFileEx, so I assume that Microsoft does the same in CopyFileEx when calling CreateFile.
How does that explain that I get a second confirmation dialog for certain overwrites ( http://ghisler.ch/board/viewtopic.php?p=149153#149153 ) whereas white doesn't.

white uses Win 98 SE, whereas I use Win XP SP2 it that it?.
Last edited by petermad on 2008-05-04, 09:46 UTC, edited 1 time in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2petermad
How does that explain that I get a second confirmation dialog for certain overwrites
Probably different settings for the copy methods?
User avatar
white
Power Member
Power Member
Posts: 4677
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Lefteous wrote:2petermad
How does that explain that I get a second confirmation dialog for certain overwrites
Probably different settings for the copy methods?
We both did test with a fresh ini-file (only changed displaying of hidden/system files)...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

It must be different behaviours of CreateFile depending on the Windows version...
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14914
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Probably different settings for the copy methods?
I think I have tried with all the possible combinations of copy methods.

It must be different behaviours of CreateFile depending on the Windows version...
Just another reason to change it so that TC behaves the same regardless of OS
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

There are indeed some OS version specific remarks in the CreateFule documentation like this:
msdn wrote:Windows Server 2003 and Windows XP/2000: If CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL are specified, CreateFile fails and sets the last error to ERROR_ACCESS_DENIED if the file exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM attribute. To avoid the error, specify the same attributes as the existing file.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I see - apparently CopyFileEx uses the attributes of the source file when creating the target. For now I will leave it as it is now, to avoid that the changes cause all sorts of other troubles, and document this difference between Win9x and NT.
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14914
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

petermad wrote:
Apparently the same happens here as with CopyFileEx, so I assume that Microsoft does the same in CopyFileEx when calling CreateFile.
How does that explain that I get a second confirmation dialog for certain overwrites ( http://ghisler.ch/board/viewtopic.php?p=149153#149153 ) whereas white doesn't.

white uses Win 98 SE, whereas I use Win XP SP2 - is that it?.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

:?:

Win98SE doesn't even support CopyFileEx!
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14914
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2white

Has this pattern: http://www.ghisler.ch/board/viewtopic.php?p=149158#149158 changed to the pattern I described ( http://www.ghisler.ch/board/viewtopic.php?p=149153#149153 ) for TC 7.50 in your Win 98 ?
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
white
Power Member
Power Member
Posts: 4677
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

petermad wrote:2white

Has this pattern: http://www.ghisler.ch/board/viewtopic.php?p=149158#149158 changed to the pattern I described ( http://www.ghisler.ch/board/viewtopic.php?p=149153#149153 ) for TC 7.50 in your Win 98 ?
No, no change.
User avatar
petermad
Power Member
Power Member
Posts: 14914
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Then I can't find the documentation as promised here: http://ghisler.ch/board/viewtopic.php?p=149361#149361

I searched the Help file and history.txt without luck. I would expect the documentation about the different warnings in Win9x and WinNT in the Help file under: Configuration - Misc.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply