views:

177

answers:

6

I sometimes have to work on code that involves me moving my clock ahead forward. In this case some .cpp or .h files get their last modification date updated to the future time as I work on them.

Later when my clock is fixed, and I go to compile, it requires a rebuild of most of the project because some of the last modification dates are in the future. Each subsequent recompile has the same problem.

My only known solution at this point is to:

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.

or 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 a recursive modification date reset tool I can run?

A: 

I don't use windows - but surely there is something like awk or grep that you can use to find the "future" timestamped files, and then "touch" them so they have the right time - even a perl script.

Michael Neale
I could make a program/script but surely there is already something made.
Brian R. Bondy
+1  A: 

I don't know if this works in your situation but how about you don't move your clock forward, but wrap your gettime method (or whatever you're using) and make it return the future time that you need?

Maximilian
+1  A: 

Install Unix Utils

touch temp
find . -newer temp -exec touch {} ;
rm temp

Make sure to use the full path when calling find or it will probably use Windows' find.exe instead. This is untested in the Windows shell -- you might need to modify the syntax a bit.

Nathan Jones
+5  A: 

I would recommend using a virtual machine where you can mess with the clock to your heart's content and it won't affect your development machine. Two free ones are Virtual PC from Microsoft and VirtualBox from Sun.

Greg Hewgill
+1  A: 

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)
Jay Bazuzi
A: 

1) Use a build system that doesn't use timestamps to detect modifications, like scons

2) Use ccache to speed up your build system that does use timestamps (and rebuild all).

In either case it is using md5sum's to verify that a file has been modified, not timestamps.

Greg Rogers