Skip to content

Commit 86f9489

Browse files
committed
More progress on macOS tests
1 parent c46dd83 commit 86f9489

File tree

8 files changed

+17
-15
lines changed

8 files changed

+17
-15
lines changed

Sources/CoreFoundation/include/ForSwiftFoundationOnly.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ CF_EXPORT struct _NSCFXMLBridgeUntyped __NSCFXMLBridgeUntyped;
339339

340340
CF_EXPORT struct _CFSwiftBridge __CFSwiftBridge;
341341

342-
CF_PRIVATE void *_Nullable _CFSwiftRetain(void *_Nullable t);
343-
CF_PRIVATE void _CFSwiftRelease(void *_Nullable t);
342+
CF_EXPORT void *_Nullable _CFSwiftRetain(void *_Nullable t);
343+
CF_EXPORT void _CFSwiftRelease(void *_Nullable t);
344344

345345
CF_EXPORT void _CFRuntimeBridgeTypeToClass(CFTypeID type, const void *isa);
346346

Sources/Foundation/FileManager.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fileprivate let UF_HIDDEN: Int32 = 1
1616
#endif
1717

1818
@_implementationOnly import _CoreFoundation
19+
1920
#if os(Windows)
2021
import CRT
2122
import WinSDK
@@ -972,7 +973,7 @@ open class FileManager : NSObject {
972973
isDirectory.boolValue {
973974
for language in _preferredLanguages {
974975
let stringsFile = dotLocalized.appendingPathComponent(language).appendingPathExtension("strings")
975-
if let data = try? Data(contentsOf: stringsFile.path),
976+
if let data = try? Data(contentsOf: stringsFile),
976977
let plist = (try? PropertyListSerialization.propertyList(from: data, format: nil)) as? NSDictionary {
977978

978979
let localizedName = (plist[nameWithoutExtension] as? NSString)?._swiftObject
@@ -1034,13 +1035,13 @@ open class FileManager : NSObject {
10341035
/* These methods are provided here for compatibility. The corresponding methods on NSData which return NSErrors should be regarded as the primary method of creating a file from an NSData or retrieving the contents of a file as an NSData.
10351036
*/
10361037
open func contents(atPath path: String) -> Data? {
1037-
return try? Data(contentsOf: path)
1038+
return try? Data(contentsOf: URL(fileURLWithPath: path))
10381039
}
10391040

10401041
@discardableResult
10411042
open func createFile(atPath path: String, contents data: Data?, attributes attr: [FileAttributeKey : Any]? = nil) -> Bool {
10421043
do {
1043-
try (data ?? Data()).write(to: path, options: .atomic)
1044+
try (data ?? Data()).write(to: URL(fileURLWithPath: path), options: .atomic)
10441045
if let attr = attr {
10451046
try self.setAttributes(attr, ofItemAtPath: path)
10461047
}

Sources/Foundation/NSArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
458458
open func write(to url: URL, atomically: Bool) -> Bool {
459459
do {
460460
let pListData = try PropertyListSerialization.data(fromPropertyList: self, format: .xml, options: 0)
461-
try pListData.write(to: url.path, options: atomically ? .atomic : [])
461+
try pListData.write(to: url, options: atomically ? .atomic : [])
462462
return true
463463
} catch {
464464
return false

Sources/Foundation/NSCharacterSet.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
@_implementationOnly import _CoreFoundation
12+
import FoundationEssentials
1213

1314
let kCFCharacterSetControl = CFCharacterSetPredefinedSet.control
1415
let kCFCharacterSetWhitespace = CFCharacterSetPredefinedSet.whitespace
@@ -186,7 +187,7 @@ open class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
186187

187188
public convenience init?(contentsOfFile fName: String) {
188189
do {
189-
let data = try Data(contentsOf: fName)
190+
let data = try Data(contentsOf: URL(fileURLWithPath: fName))
190191
self.init(bitmapRepresentation: data)
191192
} catch {
192193
return nil

Sources/Foundation/NSData.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,11 @@ extension NSData {
12071207
extension Data {
12081208
// Temporary until SwiftFoundation supports this
12091209
public init(contentsOf url: URL, options: ReadingOptions = []) throws {
1210-
self = try .init(contentsOf: url.path, options: options)
1210+
self = try .init(contentsOf: url, options: options)
12111211
}
12121212

12131213
public func write(to url: URL, options: WritingOptions = []) throws {
1214-
try write(to: url.path, options: options)
1214+
try write(to: url, options: options)
12151215
}
12161216
}
12171217

Sources/Foundation/NSDictionary.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
8282
@available(*, deprecated)
8383
public convenience init?(contentsOf url: URL) {
8484
do {
85-
guard let plistDoc = try? Data(contentsOf: url.path) else { return nil }
85+
guard let plistDoc = try? Data(contentsOf: url) else { return nil }
8686
let plistDict = try PropertyListSerialization.propertyList(from: plistDoc, options: [], format: nil) as? Dictionary<AnyHashable,Any>
8787
guard let plistDictionary = plistDict else { return nil }
8888
self.init(dictionary: plistDictionary)
@@ -509,7 +509,7 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
509509
open func write(to url: URL, atomically: Bool) -> Bool {
510510
do {
511511
let pListData = try PropertyListSerialization.data(fromPropertyList: self, format: .xml, options: 0)
512-
try pListData.write(to: url.path, options: atomically ? .atomic : [])
512+
try pListData.write(to: url, options: atomically ? .atomic : [])
513513
return true
514514
} catch {
515515
return false

Sources/Foundation/NSString.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,7 @@ extension NSString {
12591259
internal func _writeTo(_ url: URL, _ useAuxiliaryFile: Bool, _ enc: UInt) throws {
12601260
var data = Data()
12611261
try _getExternalRepresentation(&data, url, enc)
1262-
// TODO: Use URL version when that is ready
1263-
try data.write(to: url.path, options: useAuxiliaryFile ? .atomic : [])
1262+
try data.write(to: url, options: useAuxiliaryFile ? .atomic : [])
12641263
}
12651264

12661265
open func write(to url: URL, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws {

Sources/FoundationNetworking/URLSession/NetworkingSpecific.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class _NSNonfileURLContentLoader: _NSNonfileURLContentLoading {
5252
}
5353
// Temporary workaround for lack of URL in swift-foundation
5454
// TODO: Replace with argument
55-
let feURL = FoundationEssentials.URL(path: url.path)
55+
let feURL = FoundationEssentials.URL(fileURLWithPath: url.path)
5656
return CocoaError.error(.fileReadUnknown, userInfo: userInfo, url: feURL)
5757
}
5858

@@ -99,7 +99,8 @@ class _NSNonfileURLContentLoader: _NSNonfileURLContentLoading {
9999
}
100100
}
101101
throw cocoaError()
102-
} #else
102+
}
103+
#else
103104
@usableFromInline
104105
func contentsOf(url: Foundation.URL) throws -> (result: NSData, textEncodingNameIfAvailable: String?) {
105106

0 commit comments

Comments
 (0)