mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
24 lines
615 B
Swift
24 lines
615 B
Swift
import Foundation
|
|
|
|
public extension URL {
|
|
var filepath: String {
|
|
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"
|
|
}
|
|
}
|