0

I'm uncertain whether this is a platform difference or an implementation difference. I'm hoping that someone can help me shed light on that. Given this code:

filesystem::path foo("foo");
filesystem::path bar("bar");

filesystem::create_directories(foo);

filesystem::copy(foo, bar);

const auto fooftime = filesystem::last_write_time(foo);
const auto barftime = filesystem::last_write_time(bar);
const auto foocftime = decltype(fooftime)::clock::to_time_t(fooftime);
const auto barcftime = decltype(barftime)::clock::to_time_t(barftime);

cout << '(' << foocftime << ')' << asctime(localtime(&foocftime)) << '(' << barcftime << ')' << asctime(localtime(&barcftime)) << (fooftime == barftime) << endl;

gcc outputs:

(1513798777)Wed Dec 20 19:39:37 2017
(1513798777)Wed Dec 20 19:39:37 2017
1

But Visual Studio will output:

(1513798819)Wed Dec 20 14:40:19 2017
(1513798819)Wed Dec 20 14:40:19 2017
0

This seems like fooftime and barftime are equal, but when I inspect the variables in the Visual Studio debugger they contain more precision than they're outputting, and they differ in that extended precision. Can someone help me understand where the breakdown here is?

enter image description here

Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
  • What are the times you see when using the native system commands to inspect the files? And what type of file-system(s) are you using, different file-system record time with different accuracy? For example the FAT based file-systems have a time granularity of 2 seconds. – Richard Critten Dec 20 '17 at 20:44
  • @RichardCritten Unsurprisingly they both show the exact same time that is output. I don't know of any way to look at the date at a higher granularity than that. I don't really know any reason why there would need to be a higher granularity than that. – Jonathan Mee Dec 20 '17 at 21:16

0 Answers0