Skip to content

Commit

Permalink
don't implement hidden(false) for swift < 5
Browse files Browse the repository at this point in the history
and provide a warning
  • Loading branch information
ConfusedVorlon committed Jul 30, 2021
1 parent 5377bce commit dad3d84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Sources/Path+ls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/PathTests/PathTests+ls().swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit dad3d84

Please sign in to comment.