Brian R. Bondy Brian R. Bondy - 4 years ago 124
C++ Question

Resetting detection of source file changes

Sometimes I have to work on code that moves the computer clock forward. In this case some .cpp or .h files get their latest modification date set to the future time.

Later on, when my clock is fixed, and I compile my sources, system rebuilds most of the project because some of the latest modification dates are in the future. Each subsequent recompile has the same problem.

Solution that I know are:

a) Find the file that has the future time and re-save it. This method is not ideal because the project is very big and it takes time even for windows advanced search to find the files that are changed.

b) Delete the whole project and re-check it out from svn.

Does anyone know how I can get around this problem?

Is there perhaps a setting in visual studio that will allow me to tell the compiler to use the archive bit instead of the last modification date to detect source file changes?

Or perhaps there is a recursive modification date reset tool that can be used in this situation?

Answer Source

If this was my problem, I'd look for ways to avoid mucking with the system time. Isolating the code under unit tests, or a virtual machine, or something.

However, because I love PowerShell:

Get-ChildItem -r . | 
    ? { $_.LastWriteTime -gt ([DateTime]::Now) } | 
    Set-ItemProperty -Name "LastWriteTime" -Value ([DateTime]::Now)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download