Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13617] URLResourceValue.creationDate is nil on Windows #56052

Closed
swift-ci opened this issue Sep 26, 2020 · 2 comments
Closed

[SR-13617] URLResourceValue.creationDate is nil on Windows #56052

swift-ci opened this issue Sep 26, 2020 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

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.

@compnerd
Copy link
Collaborator

CC: @spevans @millenomi

@spevans - this may partially be the result of your work to use statx on Linux. The change in 692e914 dropped the else path.

@compnerd
Copy link
Collaborator

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants