Fix mtime return so it is as per doc contract

This commit is contained in:
Max Howell
2019-01-24 14:43:45 -05:00
parent ca9f1e0a74
commit 9eca479f7b

View File

@@ -51,7 +51,7 @@ public extension Path {
public var mtime: Date {
do {
let attrs = try FileManager.default.attributesOfItem(atPath: string)
return attrs[.modificationDate] as? Date ?? attrs[.creationDate] as? Date ?? Date()
return attrs[.modificationDate] as? Date ?? attrs[.creationDate] as? Date ?? Date(timeIntervalSince1970: 0)
} catch {
//TODO log error
return Date(timeIntervalSince1970: 0)