Skip to content

Commit df5fa4e

Browse files
authored
Minor fixes to support using URL in swift-corelibs-foundation (#601)
* Respect directory status when standardizing/resolving symlinks in URL * Use correct NSURLErrorKey declaration
1 parent c52b422 commit df5fa4e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/FoundationEssentials/Error/CocoaError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ extension CocoaError {
171171
public static func error(_ code: CocoaError.Code, userInfo: [String : AnyHashable]? = nil, url: URL? = nil) -> Error {
172172
var info: [String : AnyHashable] = userInfo ?? [:]
173173
if let url = url {
174-
info["NSURLErrorKey"] = url
174+
info[NSURLErrorKey] = url
175175
}
176176
return CocoaError(code, userInfo: info)
177177
}

Sources/FoundationEssentials/URL/URL.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ public struct URL: Equatable, Sendable, Hashable {
17391739
}
17401740
#endif
17411741
guard isFileURL && !fileSystemPath.isEmpty else { return self }
1742-
return URL(filePath: fileSystemPath.standardizingPath, directoryHint: .checkFileSystem)
1742+
return URL(filePath: fileSystemPath.standardizingPath, directoryHint: hasDirectoryPath ? .isDirectory : .notDirectory)
17431743
}
17441744

17451745
/// Resolves any symlinks in the path of a file URL.
@@ -1754,7 +1754,7 @@ public struct URL: Equatable, Sendable, Hashable {
17541754
}
17551755
#endif
17561756
guard isFileURL && !fileSystemPath.isEmpty else { return self }
1757-
return URL(filePath: fileSystemPath.resolvingSymlinksInPath)
1757+
return URL(filePath: fileSystemPath.resolvingSymlinksInPath, directoryHint: hasDirectoryPath ? .isDirectory : .notDirectory)
17581758
}
17591759

17601760
/// Resolves any symlinks in the path of a file URL.

0 commit comments

Comments
 (0)