Skip to content

Commit

Permalink
[FileManager] _attributesOfItem: use creationDate from the stat exten…
Browse files Browse the repository at this point in the history
…sion in

NSURL rather than repeating that logic

The last case in stat.creationDate also works for Android.
  • Loading branch information
finagolfin committed Oct 17, 2020
1 parent 9ebb444 commit e50b83b
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions Sources/Foundation/FileManager.swift
Expand Up @@ -544,14 +544,7 @@ open class FileManager : NSObject {
result[.creationDate] = creationDate
#else
let s = try _lstatFile(atPath: path)
// Darwin provides a `st_ctimespec` rather than the traditional Unix
// `st_ctime` field. Since `st_ctime` is more traditional, special case
// Darwin platforms and convert the timespec to the absolute time.
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
result[.creationDate] = Date(timespec: s.st_ctimespec)
#else
result[.creationDate] = Date(timeIntervalSince1970: TimeInterval(s.st_ctime))
#endif
result[.creationDate] = s.creationDate
#endif

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

0 comments on commit e50b83b

Please sign in to comment.