Editing a file between copy and confirmation to overwrite
Moderators: Hacker, petermad, Stefan2, white
Editing a file between copy and confirmation to overwrite
- I have a file a.txt and b.txt
- I have a.txt open in a editor in the background
- I try to copy a.txt to b.txt and get a message saying, that b.txt exists and if I want to overwrite / skip / rename / cancel ...
- I switch to the editor and change the file (remove some lines) and save the a.txt again (is now smaller)
- I switch back to TC and choose Overwrite
- TC copies a.txt to b.txt, but b.txt has now the origin (unedited) size of a.txt and have some Hex 00 at the end
- same problem, if I choose to rename to c.txt
There is no problem, if I add some lines to a.txt, only if the edited a.txt is smaller then the original one.
Suggested solution: reread the file size just before copying
best regards
Thomas
- I have a.txt open in a editor in the background
- I try to copy a.txt to b.txt and get a message saying, that b.txt exists and if I want to overwrite / skip / rename / cancel ...
- I switch to the editor and change the file (remove some lines) and save the a.txt again (is now smaller)
- I switch back to TC and choose Overwrite
- TC copies a.txt to b.txt, but b.txt has now the origin (unedited) size of a.txt and have some Hex 00 at the end
- same problem, if I choose to rename to c.txt
There is no problem, if I add some lines to a.txt, only if the edited a.txt is smaller then the original one.
Suggested solution: reread the file size just before copying
best regards
Thomas
Last edited by samot on 2008-05-15, 10:16 UTC, edited 1 time in total.
Re: Editing a file between copy and confirmation of overwrit
I cannot confirm thissamot wrote:- TC copies a.txt to b.txt, but b.txt has now the origin (unedited) size of a.txt and have some Hex 00 at the end
- same problem, if I choose to rename to c.txt
I can only confirm that the file panel not updated to show the new size of the file a.txt
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
I can reproduce now but only when the two files are in different drive format (source is FAT and Target is NTFS)ghisler(Author) wrote:What copy method do you use in TC?
I reproduced it as follows:
1. Start TC with fresh ini file. (to be sure there is not any setting in affect)
2. create a.txt in FAT volume and b.txt in NTFS volume
3. Delete some line from a.txt file and save changes while overwrite dialog is visible
after overwriting, b.txt is appended with 00 bytes
this occurs only when copying from FAT volume to NTFS volume but not occurs when copying from NTFS to FAT
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
I have checked this in a debugger now. First, I have to tell you that Total Commander does NOT copy a specific number of bytes - it simply calls ReadFile as many times as Windows returns data, until ReadFile returns an error or the read data size reported by ReadFile is smaller than the block size. So with a block size of 32768, TC calls ReadFile until ReadFile reports a returned data size of less than 32768 bytes.
The extra bytes come from the fact that TC sets the file size at the beginning of the copy operation, before writing any data to the file (via SetFilePointer and truncate). I now found a solution (calling truncate again when the copied data is less than the previously set size). I will include it in the next release.
The extra bytes come from the fact that TC sets the file size at the beginning of the copy operation, before writing any data to the file (via SetFilePointer and truncate). I now found a solution (calling truncate again when the copied data is less than the previously set size). I will include it in the next release.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Confirmed, but only for the internal copy function (Win2k SP4 and XP SP2).
With CopyCompatDrives=* I don't get this problem
(compatibility mode for all drives, that I normally have set).
[Edit]: a little too late, but the above can be used as workaround in the meantime.
With CopyCompatDrives=* I don't get this problem
(compatibility mode for all drives, that I normally have set).
[Edit]: a little too late, but the above can be used as workaround in the meantime.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
-- TC starter menu: Fast yet descriptive command access!
2ts4242
Yes, maybe I shouldn't have removed the details from my post after seeing that the problem's source is found.
I got the same results as you (failure on FAT > NTFS and NTFS > NTFS) - on the mentioned OS's.
BTW, with CopyCompatDrives=* the file system makes no difference.
Yes, maybe I shouldn't have removed the details from my post after seeing that the problem's source is found.
I got the same results as you (failure on FAT > NTFS and NTFS > NTFS) - on the mentioned OS's.

BTW, with CopyCompatDrives=* the file system makes no difference.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
-- TC starter menu: Fast yet descriptive command access!
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact: