Skip to content

Commit c0a4b5d

Browse files
authored
Merge pull request swiftlang#132 from swiftwasm/main
[pull] swiftwasm from main
2 parents 39c47d0 + fd7c1e9 commit c0a4b5d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/Foundation/FileManager.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,14 @@ open class FileManager : NSObject {
545545
result[.creationDate] = creationDate
546546
#else
547547
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
548556
#endif
549557

550558
result[.size] = NSNumber(value: UInt64(s.st_size))

0 commit comments

Comments
 (0)