-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement NSURLDirectoryEnumerator for Windows #1966
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
Conversation
Foundation/FileManager.swift
Outdated
&& file != ".." | ||
&& (_options.contains(.skipsHiddenFiles) | ||
&& (ffd.dwFileAttributes & DWORD(FILE_ATTRIBUTE_HIDDEN) == 0))) { | ||
files.append(URL(fileReferenceLiteralResourceName: "\(directory.absoluteString)\\\(file)")) |
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.
Did you mean URL(fileURLWithPath:)
?
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.
Yes I did :s
Foundation/FileManager.swift
Outdated
internal class NSURLDirectoryEnumerator : DirectoryEnumerator { | ||
internal typealias ErrorHandler = /* @escaping */ (URL, Error) -> Bool | ||
#if os(Windows) | ||
var _url : URL |
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.
Is _url
needed? It doesnt look to be used outside of init()
since it is also stored in _stack
.
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.
Nope, removed.
ffa6c31
to
7c6fb29
Compare
@swift-ci please test |
7c6fb29
to
3b9c7c2
Compare
Added a missing FindClose on the FindFirstFile handle. |
Foundation/FileManager.swift
Outdated
override func nextObject() -> Any? { | ||
let o = innerEnumerator.nextObject() | ||
guard let url = o as? URL else { | ||
return nil | ||
} | ||
|
||
#if os(Windows) | ||
NSUnimplemented() | ||
let path = url.path.replacingOccurrences(of: baseURL.path+"\\", with: "") |
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 really would prefer that we use PathRelativePathToW
here instead.
Foundation/FileManager.swift
Outdated
var _errorHandler : ((URL, Error) -> Bool)? | ||
var _stack: [URL] | ||
var _current: URL? | ||
var _root_depth : Int |
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.
_rootDepth
to follow the style please (or _depth
if you so like).
3b9c7c2
to
6788430
Compare
6788430
to
aa88f36
Compare
aa88f36
to
f2d6ee1
Compare
Removed all the absolute strings and path concatting and used the path functions instead. |
f2d6ee1
to
e548967
Compare
@swift-ci please test |
Uses
FindFirstFileW
repeatedly to enumerate the directories. The unix implementation via fts does a preorder traversal, though the order that the children are visited in seems random. The Windows implementation also shares this behaviour:FindNextFile
isn't guaranteed to be alphabetical depending on the file system.