boost::filesystem library provides portable facilities to query and manipulate paths, files, and directories.
it supports operating systems which provide either the POSIX or Windows API and is in regular use on a number of platforms (including Microsoft Windows and Sun Solaris) using a variety of compilers. programs using the library are portable, both in the syntax and the semantics of program code.
unlike most of boost, this is not a header only library. (much of the library code is platform specific. the right code is chosen based on the platform settings when building.)
here is how you could use the library to get the last modified time for a file.
"/usr/local/include/boost/filesystem/operations.hpp" ) ;
std::time_t t = boost::filesystem::last_write_time( path ) ;
std::cout << "UTC: " << std::asctime( std::gmtime(&t) ) ;
// note: some file system report last write time as local time,
// while others (eg. NTFS) report it as UTC. this can be checked
// by creating a new file and getting it's timestamp. eg.
path = "/tmp/test_file" ;
std::ofstream file( path.file_string().c_str() );
file << "test\n" ;
t = boost::filesystem::last_write_time( path ) ;
std::cout << "just created UTC: " << std::asctime( std::gmtime(&t) ) ;
>c++ -L/usr/local/lib -lboost_filesystem filesystem.cc && ./a.out
UTC: Tue Aug 14 13:17:48 2007
just created UTC: Mon Oct 15 15:13:39 2007