-
Notifications
You must be signed in to change notification settings - Fork 190
[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
[Windows] Implement additional file attributes #730
Conversation
@swift-ci please test |
Sources/FoundationEssentials/FileManager/FileManager+Files.swift
Outdated
Show resolved
Hide resolved
let systemFileNumber = UInt64(info.nFileIndexHigh << 32) | UInt64(info.nFileIndexLow) | ||
let referenceCount = UInt64(info.nNumberOfLinks) | ||
|
||
let isReadOnly = info.dwFileAttributes & FILE_ATTRIBUTE_READONLY != 0 |
There was a problem hiding this comment.
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 ...
let isReadOnly = info.dwFileAttributes & FILE_ATTRIBUTE_READONLY != 0 | |
let isReadOnly = info.dwFileAttributes & FILE_ATTRIBUTE_READONLY == FILE_ATTRIBUTE_READONLY |
There was a problem hiding this comment.
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).
Sources/FoundationEssentials/FileManager/FileManager+Files.swift
Outdated
Show resolved
Hide resolved
Sources/FoundationEssentials/FileManager/FileManager+Files.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
Sources/FoundationEssentials/FileManager/FileManager+Files.swift
Outdated
Show resolved
Hide resolved
@swift-ci please test |
This implements the remaining attributes for
attributesOfItem(atPath:)
for windows. This is required for the Windows toolchain build becauseTSCBasic
requires these attributes andswiftc.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).