don't implement hidden(false) for swift < 5
and provide a warning
This commit is contained in:
@@ -53,12 +53,12 @@ extension Path.Finder: Sequence, IteratorProtocol {
|
||||
if enumerator.level < depth.lowerBound {
|
||||
continue
|
||||
}
|
||||
#endif
|
||||
|
||||
if !hidden, path.basename().hasPrefix(".") {
|
||||
enumerator.skipDescendants()
|
||||
continue
|
||||
}
|
||||
#endif
|
||||
if let type = path.type, !types.contains(type) { continue }
|
||||
if let exts = extensions, !exts.contains(path.extension) { continue }
|
||||
return path
|
||||
@@ -124,6 +124,9 @@ public extension Path.Finder {
|
||||
|
||||
/// Whether to skip hidden files and folders.
|
||||
func hidden(_ hidden: Bool) -> Path.Finder {
|
||||
#if os(Linux) && !swift(>=5.0)
|
||||
fputs("warning: hidden not implemented for Swift < 5\n", stderr)
|
||||
#endif
|
||||
self.hidden = hidden
|
||||
return self
|
||||
}
|
||||
|
||||
@@ -149,11 +149,12 @@ extension PathTests {
|
||||
Set([dotFoo,tmpDotA,tmpDotAFoo,tmpB,tmpBFoo]),
|
||||
relativeTo: tmpdir)
|
||||
|
||||
#if !os(Linux) || swift(>=5)
|
||||
XCTAssertEqual(
|
||||
Set(tmpdir.find().hidden(false)),
|
||||
Set([tmpB,tmpBFoo]),
|
||||
relativeTo: tmpdir)
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user