Page 1 of 1

Compare files by content (binary) - disk cache

Posted: 07 Jun 2006, 14:58
by Marcel_G
Hi there

I often use the "compare directories" function to verify burned CDs and to check backups and so on. But sometimes the comparison is done very quickly even on larger files. E.g. if I burn 2 CDs with same content (2 Backups for archive) or if I copy the data via network to another PC, the compare tool does not read from disk or CD again, it reads from the cache.

So I'm not sure if the file really can be read from disk again and its content is correct, right? I assume windows cache management does its work here, but is there a way that ServantSalamander can read data without using the cache for content comparison?

Kind regards,
Marcel

Posted: 07 Jun 2006, 15:45
by Jan Rysavy
Unfortunately we have no idea how to invalidate or bypass the Windows read cache, I'm sorry.

Posted: 07 Jun 2006, 16:19
by Tomas Kopal
For comparing burnt CD, I eject the disk and insert it again. That invalidates the cache quite well. Don't forget to select the option to compare contents of the files, not just dates!
If you need to do this with non-removable media, you are probably out of luck.

Posted: 08 Jun 2006, 10:19
by Marcel_G
I don't know if there is a "unbuffered reader", but most C++ have the possibility to clear the stream buffer. But I'm not sure if this affects windows disk or file cache.

streambuf::sync

Here a link to this function in Microsoft Visual C++ 6.0 on the MSDN:
http://msdn.microsoft.com/library/defau ... a.sync.asp

Posted: 08 Jun 2006, 11:18
by Datalog
Marcel_G wrote:I don't know if there is a "unbuffered reader", but most C++ have the possibility to clear the stream buffer. But I'm not sure if this affects windows disk or file cache.

streambuf::sync

Here a link to this function in Microsoft Visual C++ 6.0 on the MSDN:
http://msdn.microsoft.com/library/defau ... a.sync.asp
Streambuf is higher level function. Really low level API is: FlushFileBuffers or CreateFile with FILE_FLAG_NO_BUFFERING. BUT, both of them affects writing only. For compare it's necessary to invalidate disk read cache - but it is not possible under MS Windows (or not known to me - i.e. it's not in base API).

Posted: 08 Jun 2006, 11:59
by Marcel_G
Ok, there seems to be no way, except perhaps to reboot the system befor compare files... :?

Posted: 08 Jun 2006, 12:47
by Jan Rysavy
Marcel, try to open the Find window (Alt+F7) on root of your hard disk and search files content for some dummy string. I suppose the read cache becomes invalidated quickly... an empiric approach :)