Skip to content

Commit dad3d84

Browse files
don't implement hidden(false) for swift < 5
and provide a warning
1 parent 5377bce commit dad3d84

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Sources/Path+ls.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ extension Path.Finder: Sequence, IteratorProtocol {
5353
if enumerator.level < depth.lowerBound {
5454
continue
5555
}
56-
#endif
57-
56+
5857
if !hidden, path.basename().hasPrefix(".") {
5958
enumerator.skipDescendants()
6059
continue
6160
}
61+
#endif
6262
if let type = path.type, !types.contains(type) { continue }
6363
if let exts = extensions, !exts.contains(path.extension) { continue }
6464
return path
@@ -124,6 +124,9 @@ public extension Path.Finder {
124124

125125
/// Whether to skip hidden files and folders.
126126
func hidden(_ hidden: Bool) -> Path.Finder {
127+
#if os(Linux) && !swift(>=5.0)
128+
fputs("warning: hidden not implemented for Swift < 5\n", stderr)
129+
#endif
127130
self.hidden = hidden
128131
return self
129132
}

Tests/PathTests/PathTests+ls().swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ extension PathTests {
149149
Set([dotFoo,tmpDotA,tmpDotAFoo,tmpB,tmpBFoo]),
150150
relativeTo: tmpdir)
151151

152+
#if !os(Linux) || swift(>=5)
152153
XCTAssertEqual(
153154
Set(tmpdir.find().hidden(false)),
154155
Set([tmpB,tmpBFoo]),
155156
relativeTo: tmpdir)
156-
157+
#endif
157158
}
158159
}
159160

0 commit comments

Comments
 (0)