Skip to content

Commit 4c26af5

Browse files
authored
FoundationEssentials: drop invalid modification dates (#628)
Follow the expected behaviour to drop invalid modification dates, e.g. `+NaN`. This matches the semantics that are expected on Unix and avoids a crash due to the initialiser.
1 parent 7ce7be4 commit 4c26af5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/FoundationEssentials/FileManager/FileManager+Files.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,10 @@ extension _FileManagerImpl {
718718
let seconds = modification.timeIntervalSince1601
719719

720720
var uiTime: ULARGE_INTEGER = .init()
721-
uiTime.QuadPart = UInt64(seconds * 10000000)
721+
guard let converted = UInt64(exactly: seconds * 10000000.0) else {
722+
return
723+
}
724+
uiTime.QuadPart = converted
722725

723726
var ftTime: FILETIME = .init()
724727
ftTime.dwLowDateTime = uiTime.LowPart

0 commit comments

Comments
 (0)