Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit aea7f90

Browse files
authored
Merge pull request #14 from SwiftDocOrg/mattt/fix-dot-swift-directories
Ensure enumerated paths are readable files with .swift file extension
2 parents 1d51e24 + d72b56a commit aea7f90

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Sources/swift-api-inventory/main.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ command(
2323
let directory = URL(fileURLWithPath: path)
2424
guard let directoryEnumerator = fileManager.enumerator(at: directory, includingPropertiesForKeys: nil) else { continue }
2525
for case let url as URL in directoryEnumerator {
26-
guard url.pathExtension == "swift" else { continue }
26+
var isDirectory: ObjCBool = false
27+
guard url.pathExtension == "swift",
28+
fileManager.isReadableFile(atPath: url.path),
29+
fileManager.fileExists(atPath: url.path, isDirectory: &isDirectory),
30+
isDirectory.boolValue == false
31+
else { continue }
2732
sourceFiles.append(try SourceFile(file: url, relativeTo: directory))
2833
}
2934
}

Sources/swift-dcov/main.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ command(
2222
let directory = URL(fileURLWithPath: path)
2323
guard let directoryEnumerator = fileManager.enumerator(at: directory, includingPropertiesForKeys: nil) else { continue }
2424
for case let url as URL in directoryEnumerator {
25-
guard url.pathExtension == "swift" else { continue }
25+
var isDirectory: ObjCBool = false
26+
guard url.pathExtension == "swift",
27+
fileManager.isReadableFile(atPath: url.path),
28+
fileManager.fileExists(atPath: url.path, isDirectory: &isDirectory),
29+
isDirectory.boolValue == false
30+
else { continue }
2631
sourceFiles.append(try SourceFile(file: url, relativeTo: directory))
2732
}
2833
}

Sources/swift-doc/main.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ command(
2828
let directory = URL(fileURLWithPath: path)
2929
guard let directoryEnumerator = fileManager.enumerator(at: directory, includingPropertiesForKeys: nil) else { continue }
3030
for case let url as URL in directoryEnumerator {
31-
guard url.pathExtension == "swift" else { continue }
31+
var isDirectory: ObjCBool = false
32+
guard url.pathExtension == "swift",
33+
fileManager.isReadableFile(atPath: url.path),
34+
fileManager.fileExists(atPath: url.path, isDirectory: &isDirectory),
35+
isDirectory.boolValue == false
36+
else { continue }
3237
sourceFiles.append(try SourceFile(file: url, relativeTo: directory))
3338
}
3439
}

0 commit comments

Comments
 (0)