Skip to content

Commit e2828b9

Browse files
author
Sergey Minakov
committed
Make NSURL return error on nonFileURL (Matches Darwin).
1 parent 58c1e7f commit e2828b9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Foundation/NSURL.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,11 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
613613
open func checkResourceIsReachableAndReturnError(_ error: UnsafeMutablePointer<NSError?>?) -> Bool {
614614
guard isFileURL,
615615
let path = path else {
616-
return false
616+
if let error = error {
617+
error.pointee = NSError(domain: NSCocoaErrorDomain,
618+
code: CocoaError.Code.fileNoSuchFile.rawValue)
619+
}
620+
return false
617621
}
618622

619623
guard FileManager.default.fileExists(atPath: path) else {

0 commit comments

Comments
 (0)