Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Serious Data corruption bug in "Compare by content"
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Total Commander Forum Index -> TC7.56(a)/7.57 bug reports (English) Printable version
View previous topic :: View next topic  
Author Message
milo1012
Junior Member
Junior Member


Joined: 02 Feb 2012
Posts: 60

PostPosted: Sun Feb 05, 2012 1:51 pm    Post subject: Reply with quote

umbra wrote:
So it's no wonder it emulates Notepad as much as possible. Smile

Of course it is...but the exact behavior of Windows Notepad in terms of file handling is not documented and can only be observed.
What I mean is that every Program approaches that different...programming file handling in MFC in Visual Studio is completely different than in .Net, JAVA or things like MinGW.
So propably, if you don't follow file handling recommendations from Microsoft or it's just your goal to be able to do it anyway then you end up like this: we have a lot of programs that allow writing locked files and many that don't.
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4599
Location: Russian Federation

PostPosted: Sun Feb 05, 2012 11:38 pm    Post subject: Reply with quote

Well, I've tested it with WordPad, it doesn't allow to save file. Maybe it checks it somehow.

It is strange but I can't save a file using standard Notepad if it was opened by following sample code:
Code:
   HANDLE hfile=CreateFile(L"D:\\testfile.txt", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
   HANDLE hmap=CreateFileMapping(hfile, 0, PAGE_READWRITE, 0, 0, 0);

   MessageBox(0, L"1", L"2", 0);
   CloseHandle(hmap);
   CloseHandle(hfile);

BTW, it works correctly even with FILE_SHARE_READ|FILE_SHARE_WRITE sharing flags! Notepad is unable to save file until I click a button in a message box.
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24702
Location: Switzerland

PostPosted: Mon Feb 06, 2012 10:36 am    Post subject: Reply with quote

I'm opening the file with GENERIC_READ access and sharing flags set to
FILE_SHARE_READ | FILE_SHARE_WRITE. This is done so I can also compare files which are currently open in some other program. If I used only FILE_SHARE_READ, I couldn't open e.g. active database files.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4599
Location: Russian Federation

PostPosted: Mon Feb 06, 2012 1:48 pm    Post subject: Reply with quote

Maybe you should try to open with just FILE_SHARE_READ at first? You can then open with both FILE_SHARE_READ|FILE_SHARE_WRITE on fail - in such case you may disable 'edit' button or show a message to user. Anyway you can't edit binary files.
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24702
Location: Switzerland

PostPosted: Thu Feb 09, 2012 9:25 am    Post subject: Reply with quote

Your sugestion to try with FILE_SHARE_READ first is good. Btw, the problem isn't about editing the file with TC, but with an external editor.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4599
Location: Russian Federation

PostPosted: Thu Feb 09, 2012 10:08 am    Post subject: Reply with quote

Problem is that external editor is able to open end edit file while it is mapped. We see that many editors can't check if file is mapped, so we should try to prevent them from modifying a file.
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24702
Location: Switzerland

PostPosted: Fri Feb 10, 2012 5:31 am    Post subject: Reply with quote

OK, try beta 19.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4599
Location: Russian Federation

PostPosted: Fri Feb 10, 2012 6:06 am    Post subject: Reply with quote

Nice, file is locked while it is being compared in b19.
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
umbra
Power Member
Power Member


Joined: 14 Jan 2012
Posts: 675

PostPosted: Fri Feb 10, 2012 6:51 am    Post subject: Reply with quote

In beta 19, if some file is larger than 1 MiB it's locked.

However the help says:
Quote:
Files up to 2 MB will be loaded completely into memory, so the originals will remain editable. Larger files will only be mapped to memory, i.e. they remain locked during the comparison.

Are those 2 MiB a typo or I'm missing something?
_________________
Windows 7 Pro x64, Windows 8 Pro x64
Back to top
View user's profile Send private message Send e-mail
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24702
Location: Switzerland

PostPosted: Fri Feb 10, 2012 7:25 am    Post subject: Reply with quote

It's badly explained, the 2 MB is the memory it may take when both files are loaded into memory.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> TC7.56(a)/7.57 bug reports (English) All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group