From dad3d8404098689d014ed51bc6f403193dbc7e02 Mon Sep 17 00:00:00 2001 From: Rob Jonson Date: Fri, 30 Jul 2021 17:09:37 +0100 Subject: [PATCH] don't implement hidden(false) for swift < 5 and provide a warning --- Sources/Path+ls.swift | 7 +++++-- Tests/PathTests/PathTests+ls().swift | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/Path+ls.swift b/Sources/Path+ls.swift index c97397e..0b627a3 100644 --- a/Sources/Path+ls.swift +++ b/Sources/Path+ls.swift @@ -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 } diff --git a/Tests/PathTests/PathTests+ls().swift b/Tests/PathTests/PathTests+ls().swift index 1c856e7..58072d3 100644 --- a/Tests/PathTests/PathTests+ls().swift +++ b/Tests/PathTests/PathTests+ls().swift @@ -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 } }