last_write_time复制目录不匹配

时间:2017-12-20 19:47:39

标签: c++ visual-studio gcc directory copy

我不确定这是平台差异还是实现差异。我希望有人可以帮助我阐明这一点。鉴于此代码:

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

但Visual Studio将输出:

  

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

这看起来像fooftimebarftime是相同的,但是当我检查Visual Studio调试器中的变量时,它们包含的精度比它们输出的精度要高,并且它们的扩展不同精度的。有人可以帮我理解这里的故障在哪里吗?

enter image description here

0 个答案:

没有答案