Reputation: 13876
I'm learning how to use the new C++ filesystem library, and I've seen examples of how to implement a folder monitor that does three simple things: detects file creation; file modification; and file deletion. It works by searching the entire folder every set period of time, eg., 1000 milliseconds, and checks each file entry in the filesystem against another record kept by you're own code, for example an unordered_map/hash table, so that each time record is updated the filesystem is queried to get the name of each file in the folder, then this name is searched in your record of the existing files. This happens for the number of files in the folder.
I was wondering if there are more efficient way to handle this, such as adding to an array or queue each modification detected by the operating system, so that each time your monitor updates it just checks if anything has been placed in this array for a file creation, deletion or modification, as opposed to checking the differences between each file in the filesystem with your record of the file.
Upvotes: 0
Views: 59
Reputation: 13876
It turns out the method I've mentioned is a polling method, whereas I'm looking for an event-based method so that you're notified of any changes. However those seem to be platform-dependent.
Upvotes: 0