mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Introduce guarded filepath provider for file collection (#6435)
This commit is contained in:
@@ -5,6 +5,18 @@ public extension URL {
|
||||
withUnsafeFileSystemRepresentation { String(cString: $0!) }
|
||||
}
|
||||
|
||||
var filepathGuarded: String? {
|
||||
withUnsafeFileSystemRepresentation { ptr in
|
||||
guard let ptr else {
|
||||
Issue.genericError(
|
||||
"File with URL '\(self)' cannot be represented as a file system path; skipping it"
|
||||
).print()
|
||||
return nil
|
||||
}
|
||||
return String(cString: ptr)
|
||||
}
|
||||
}
|
||||
|
||||
var isSwiftFile: Bool {
|
||||
filepath.isFile && pathExtension == "swift"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user