I have a utility that processes a set of files in a directory - the process is relatively slow (and there are many files), and therefore I tried to optimize the process only with process files that have the "last change" later than the last processing date.
This usually works well, however, I found that since copying a file does not change the last modified date, and therefore there are various scenarios related to copying files in which certain files that have been modified are skipped by the process, for example
- The user processes the directory at 9:00.
- The file is then copied from this directory and changed so that it has the last modified date of 9:30
- Then the directory is processed again at 10:00
- The modified file is then copied back to the directory at 10:30
- Finally, the directory is processed again at 11:00.
Since the modified date of this file is 9:30, and the last time the directory is processed at 10:00, the file is skipped when it should not be.
Unfortunately, the above often happens too often in certain situations (for example, in a collaborative environment with source control, etc.). It is clear that my logic is wrong - I really need the date of the last change or copy. does such a thing exist?
Otherwise, is there another way to quickly determine with reasonable reliability if this file has changed?
source
share