don't implement hidden(false) for swift < 5

and provide a warning
This commit is contained in:
Rob Jonson
2021-07-30 17:09:37 +01:00
parent 5377bceb5f
commit dad3d84040
2 changed files with 7 additions and 3 deletions

View File

@@ -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
} }

View File

@@ -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
} }
} }