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 {
|
if enumerator.level < depth.lowerBound {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if !hidden, path.basename().hasPrefix(".") {
|
if !hidden, path.basename().hasPrefix(".") {
|
||||||
enumerator.skipDescendants()
|
enumerator.skipDescendants()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if let type = path.type, !types.contains(type) { continue }
|
if let type = path.type, !types.contains(type) { continue }
|
||||||
if let exts = extensions, !exts.contains(path.extension) { continue }
|
if let exts = extensions, !exts.contains(path.extension) { continue }
|
||||||
return path
|
return path
|
||||||
@@ -124,6 +124,9 @@ public extension Path.Finder {
|
|||||||
|
|
||||||
/// Whether to skip hidden files and folders.
|
/// Whether to skip hidden files and folders.
|
||||||
func hidden(_ hidden: Bool) -> Path.Finder {
|
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
|
self.hidden = hidden
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,11 +149,12 @@ extension PathTests {
|
|||||||
Set([dotFoo,tmpDotA,tmpDotAFoo,tmpB,tmpBFoo]),
|
Set([dotFoo,tmpDotA,tmpDotAFoo,tmpB,tmpBFoo]),
|
||||||
relativeTo: tmpdir)
|
relativeTo: tmpdir)
|
||||||
|
|
||||||
|
#if !os(Linux) || swift(>=5)
|
||||||
XCTAssertEqual(
|
XCTAssertEqual(
|
||||||
Set(tmpdir.find().hidden(false)),
|
Set(tmpdir.find().hidden(false)),
|
||||||
Set([tmpB,tmpBFoo]),
|
Set([tmpB,tmpBFoo]),
|
||||||
relativeTo: tmpdir)
|
relativeTo: tmpdir)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user