Information Systems



How do I change a file mod time in c++?

This is the windows version. The Unix version is pretty much the same, except you don't have the funny underscores.

#include <sys/utime.h>

void setFileModSeconds(const std::string &s, time_t seconds)
{
_utimbuf tb;
tb.actime = seconds;
tb.modtime = seconds;
_utime(s.c_str(), &tb);
}