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