last_write_time Mismatch on Copied Directories

北城余情 提交于 2019-12-14 03:15:34

问题


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?

来源:https://stackoverflow.com/questions/47913379/last-write-time-mismatch-on-copied-directories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!