-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement _lstatFile on Windows #2015
Conversation
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.
This is going to be extremely helpful to me!
Foundation/FileManager.swift
Outdated
@@ -1818,19 +1817,70 @@ open class FileManager : NSObject { | |||
} | |||
|
|||
var statInfo = stat() | |||
#if os(Windows) | |||
let h = path.withCString(encodedAs: UTF16.self) { | |||
CreateFileW( /*lpFileName=*/$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.
Nit: Extra whitespace.
Foundation/FileManager.swift
Outdated
if err == ERROR_FILE_NOT_FOUND { | ||
errno = ENOENT | ||
} | ||
throw _NSErrorWithErrno(errno, reading: true, path: path) |
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.
Just replace this with _NSErrorWithWindowsError
Foundation/FileManager.swift
Outdated
// themselves, we say symlinks are regular files | ||
UInt16((info.dwFileAttributes & DWORD(FILE_ATTRIBUTE_REPARSE_POINT)) != 0 | ||
? _S_IFREG | ||
: (info.dwFileAttributes & DWORD(FILE_ATTRIBUTE_DIRECTORY)) != 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.
Can you extract the checks into variables please, it makes it easier to read.
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.
Done
Windows doesn't have lstat, but it still can be implemented. This should help remove some of the Windows specific codepaths.
f419d5a
to
a62b609
Compare
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.
This looks great!
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
Windows doesn't have lstat, but it still can be implemented. This should
help remove some of the Windows specific codepaths.
This is based off the lstat in llbuild
Also depends on swiftlang/swift#23342