Check it out. its usefull for comparing big files.


http://tejo.yourdotstore.com/~diablo.com/downloads/CompareFile_DLL.rar
Posted on 2004-12-09 15:40:21 by diablo2oo2
You might consider using another approach which may be a little more efficient. This would be to use CreateFile/CreateFileMapping/MapViewOfFile on the two files and then compare them with cmpsd instead of cmpsb (with standard cmps for non-aligned bytes).

Posted on 2004-12-09 15:55:39 by nohaven
File mapping isn't as efficient as normal file I/O, and is severely handicapped on 9x because of the shared address space. Highest performance will be achieved if you use overlapped (async) file I/O.
Posted on 2004-12-10 03:42:16 by f0dder
then compare them with cmpsd instead of cmpsb


i checked this. but i dont see any differnece with the compare speed.

Highest performance will be achieved if you use overlapped (async) file I/O.

dont know what that is but i read that it doesnt run under win98. anyway i think the procedure is fast enough for comparing big files.

just the cpu usage is very high (100%), is that normal with cmpsb/cmpsd ?
Posted on 2004-12-10 08:17:48 by diablo2oo2
Why are you doing SetFilePointer in the compare loop? Aren't you just comparing the first block continously this way?

There are faster ways to compare memory blocks than "rep cmps*", unroll the loop or use MMX or whatever. Probably won't matter too much since you should be I/O bound, but still...

Again, doesn't matter too much in this context, but "shr ecx, 2" is faster than your DIV before the cmpsd. And even when "memsize != ecx", you could start doing CMPSD's, and handle the remaining bytes with CMPSB.

You have a possible memory leak... if memory #2 alloc fails, you jump to @failed, which doesn't freem memory #1 block.

...
Posted on 2004-12-10 08:32:15 by f0dder
Why are you doing SetFilePointer in the compare loop? Aren't you just comparing the first block continously this way?

i code such thing first time. never used SetFilePointer befor. so do you think i must inrease the "distance to move" on every loop? i check it.

but "shr ecx, 2" is faster than your DIV

nice trick. asm is great. i like it


You have a possible memory leak... if memory #2 alloc fails, you jump to @failed, which doesn't freem memory #1 block

thanks for this bug report.
Posted on 2004-12-10 08:51:58 by diablo2oo2
You don't need SetFilePointer at all - using ReadFile automatically increases the file pointer position. When you do invoke SetFilePointer,hFile_1,MemSize,NULL,FILE_BEGIN, you set the file pointer to MemSize bytes into the file... which means you will always process the second (not first, as I wrote earlier) block. Simply remove these two lines :)
Posted on 2004-12-10 08:59:25 by f0dder
thanks again. i think it should work now... hope it...
Posted on 2004-12-10 09:15:28 by diablo2oo2
Could anybody help me to translate the API Declaration to HL Syntax?
Cause i coded this for a friend. He tried to use this witch a delphi app but he has problems.

CompareFiles(

LPCTSTR pFile_1, // Adress of buffer of Path of File 1
LPCTSTR pFile_2, // Adress of buffer of Path of File 2
DWORD pMemUsage // MemUsage per File in MegaBytes
DWORD pUseProgressWindows // 1=Show Window 0=Hide Window
)
Posted on 2004-12-12 08:19:40 by diablo2oo2
function CompareFiles(pFile_1,pFile_2:PCHAR; pMemUsage,pUseProgressWindows:DWORD):Integer; stdcall; external 'CompareFiles.dll' name 'CompareFiles';
:roll:
Posted on 2004-12-12 13:54:48 by drizz
thanks, it works now in with delphi.
Posted on 2004-12-12 14:01:12 by diablo2oo2