Detect file system changes since last scan

Programs that index file systems seem to know which parts have changed since their last index, and only re-scan that part. How to determine where the file system / files has changed since my last index. I don't care what language you answer, but I think c and windows.

An example of such a program is Sequoia View, which generates a treemap of your hard drive.

+3
source share
6 answers

A fairly simple method is to take the size of files registered in the file system, dates (as integer values) and file names in a given directory and calculate checksum , you can then link to this directory. You will still need to perform this calculation in all directories using the file system data, but you will not need to go deeper (opening files to check for differences) if the checksum did not report the differences.

To track specific changes at the file level, you must store checksums based on individual file attributes, as well as, of course, the presence or absence of files and subdirectories since the last scan.

, , , .

fswatch .

+6

.Net- , FileSystemWatcher.

MSDN:

FileSystemWatcher . . , .

, Filter ( ") (". "). , . , MyDoc.txt, " MyDoc.txt ". . , , " *.txt".

+4

2 , .

-, ( ). Windows API ReadDirectoryChangesW. - , . (... . API CAN AND WILL , , , , , .

, , , - / .

. , ( - GetFileAttributesEx) . (, "." ".." - .)

, , .. , LastAccessed.

. () .

, , . , .

, (), -, , , , .

, , , . , .

+4

.

+3

FindFirstChangeNotification

+1

On Linux (and any other Unix-like OS, I suppose), it would be possible to generate a hash value for the file / folder to represent its state at a given time. Later just restore the hash and compare it to the old value. This has been very effective for some of the projects I'm working on!

Details here: http://vpalos.com/169/recursive-filedirectory-change-detection/

It is sensitive to any changes (even when changing the file access time).

+1
source

Source: https://habr.com/ru/post/1698911/


All Articles