Portable way to set file modification time in C++?

Viewed 1747

I'm writing a C++ application that needs to be portable between at least Ubuntu 15, FreeBSD 11, MacOS X and Windows 7 (compiled with GCC, clang and MSVC). All of these systems have a notion of a file with at least a modification date/time.

The question is: is there a way to set a file modification time using a single piece of C++ code that would work on all of these systems?

NB: By setting the file modification time I mean setting it to any specified value, not the current time (i.e. not the touch functionality).

2 Answers
Related