-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Description
| Previous ID | SR-13617 |
| Radar | None |
| Original Reporter | klcantrell (JIRA User) |
| Type | Bug |
| Status | Closed |
| Resolution | Done |
Environment
Windows 5.3-RELEASE
Windows 10 build: 18362.1082
Build tools version: MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.27)
Windows SDK installed: 10.0.18362.0
Additional Detail from JIRA
| Votes | 0 |
| Component/s | |
| Labels | Bug, windows |
| Assignee | @compnerd |
| Priority | Medium |
md5: 9f34ab8d4d64f3ed7358d033104b9a65
Issue Description:
There appears to be a bug that is preventing the retrieval of the `creationDate` of a file when running on Windows. Assuming `zoo.txt` exists, the following is a minimal-ish reproduction of the issue. Given this code:
import Foundation
let workingDirectoryUrl = URL(fileURLWithPath: Bundle.main.resourcePath!)
let fileUrl = URL(fileURLWithPath: "zoo.txt", relativeTo: workingDirectoryUrl)
let fileAttributes = try! fileUrl.resourceValues(forKeys: [.nameKey, .creationDateKey])
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.timeStyle = .medium
let formattedName = fileAttributes.name ?? "unknown name"
let formattedDate = fileAttributes.creationDate.map { formatter.string(from: $0) }
?? "unknown date"
print("Found \(formattedName), created \(formattedDate)")
The output is `Found zoo.txt, created unknown date`.
Simply changing `creationDateKey` and `creationDate` to `contentModificationDateKey` and `contentModificationDate`, respectively, will yield an actual date.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.