Skip to content

[Windows] Implement additional file attributes #730

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

Merged
merged 5 commits into from
Jul 12, 2024

Conversation

jmschonfeld
Copy link
Contributor

This implements the remaining attributes for attributesOfItem(atPath:) for windows. This is required for the Windows toolchain build because TSCBasic requires these attributes and swiftc.exe ends up calling down to this API while compiling SwiftPM manifests.

The implementation of all of these attributes comes from the existing sources in swift-corelibs-foundation (roughly).

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

let systemFileNumber = UInt64(info.nFileIndexHigh << 32) | UInt64(info.nFileIndexLow)
let referenceCount = UInt64(info.nNumberOfLinks)

let isReadOnly = info.dwFileAttributes & FILE_ATTRIBUTE_READONLY != 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is safer to ensure that the bit is set ...

Suggested change
let isReadOnly = info.dwFileAttributes & FILE_ATTRIBUTE_READONLY != 0
let isReadOnly = info.dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I prefer the != 0 version. If we're doing a bitwise AND, we know the answer is either 0 or FILE_ATTRIBUTE_READONLY. The only way we could trip up is if FILE_ATTRIBUTE_READONLY is not really a bit mask, but that would be wrong for either formulation (and we already know it's a bit mask anyway).

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit 7f9238e into swiftlang:main Jul 12, 2024
3 checks passed
@jmschonfeld jmschonfeld deleted the windows/extra-attributes branch July 12, 2024 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants