We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 82b8fa2 + 3eda66b commit fd7c1e9Copy full SHA for fd7c1e9
Sources/Foundation/FileManager.swift
@@ -544,6 +544,14 @@ open class FileManager : NSObject {
544
result[.creationDate] = creationDate
545
#else
546
let s = try _lstatFile(atPath: path)
547
+ // Darwin provides a `st_ctimespec` rather than the traditional Unix
548
+ // `st_ctime` field. Since `st_ctime` is more traditional, special case
549
+ // Darwin platforms and convert the timespec to the absolute time.
550
+#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
551
+ result[.creationDate] = Date(timespec: s.st_ctimespec)
552
+#else
553
+ result[.creationDate] = Date(timeIntervalSince1970: TimeInterval(s.st_ctime))
554
+#endif
555
#endif
556
557
result[.size] = NSNumber(value: UInt64(s.st_size))
0 commit comments