Comment #0 by n8sh.secondary — 2020-04-29T04:31:15Z
This was brought to my attention by a unit test in https://github.com/CyberShadow/ae/blob/master/sys/persistence/core.d that was failing on macOS because it was storing a result of `timeLastModified` then using the stored value as an argument to `setTimes` and expecting that the next call to `timeLastModified` would yield the same result as the stored value. The problem is that on macOS std.file uses hecto-nanosecond precision (converted from nanosecond) when reading file access/modification times but only uses microsecond precision when writing them. This is because core.sys.posix.sys.stat does not have `utimensat` for macOS, which is because it only became available in macOS starting from version 10.13 which was released in 2017. As an alternative `setattrlist` can be used with any version of macOS to set timestamps with the same precision as `utimensat`.
Comment #1 by dlang-bot — 2020-04-29T04:35:48Z
@n8sh created dlang/phobos pull request #7466 "std.file.setTimes: on macOS use setattrlist to avoid truncating timestamp precision to microseconds" fixing this issue:
- Fix Issue 20785 - std.file.setTimes: on macOS use setattrlist to avoid truncating timestamp precision to microseconds
https://github.com/dlang/phobos/pull/7466
Comment #2 by dlang-bot — 2020-05-19T14:35:57Z
dlang/phobos pull request #7466 "std.file.setTimes: on macOS use setattrlist to avoid truncating timestamp precision to microseconds" was merged into stable:
- dfb9099055eb4ec2603ee0b827dfa022310d4fb0 by Nathan Sashihara:
Fix Issue 20785 - std.file.setTimes: on macOS use setattrlist to avoid truncating timestamp precision to microseconds
https://github.com/dlang/phobos/pull/7466