@@ -109,13 +109,13 @@ extension NSURL {
109109 return URLEncoder . percentEncode ( string: path, encoding: encoding, component: component, skipAlreadyEncoded: false )
110110 }
111111
112- static func __copySwiftEncodedFSRPath( _ path: String ) -> String ? {
112+ static func __copySwiftEncodedFSRPath( _ path: String ) -> Unmanaged < CFString > ? {
113113 guard !path. isEmpty else {
114- return path
114+ return _createCFStringFromASCIIString ( path)
115115 }
116116 // Convert path to its decomposed file system representation then encode
117117 let maxFSRSize = 3 * path. utf8. count
118- return withUnsafeTemporaryAllocation ( of: UInt8 . self, capacity: maxFSRSize) { pathBuffer -> String ? in
118+ return withUnsafeTemporaryAllocation ( of: UInt8 . self, capacity: maxFSRSize) { pathBuffer in
119119 guard var pathLength = path. _decomposed ( . hfsPlus, into: pathBuffer) else {
120120 return nil
121121 }
@@ -124,15 +124,14 @@ extension NSURL {
124124 while pathLength > rootLength && pathBuffer [ pathLength - 1 ] == UInt8 ( ascii: " / " ) {
125125 pathLength -= 1
126126 }
127- return withUnsafeTemporaryAllocation ( of : UInt8 . self , capacity: 3 * pathLength) { encodedBuffer in
128- let encodedLength = URLEncoder . percentEncodeUnchecked (
127+ return _createCFStringFromASCIIBuffer ( capacity: 3 * pathLength) { encodedBuffer in
128+ URLEncoder . percentEncodeUnchecked (
129129 input: UnsafeBufferPointer ( rebasing: pathBuffer [ ..< pathLength] ) ,
130130 output: encodedBuffer,
131131 // Encode ";" for compatibility
132132 component: . pathNoSemicolon,
133133 skipAlreadyEncoded: false
134134 )
135- return String ( decoding: encodedBuffer [ ..< encodedLength] , as: UTF8 . self)
136135 }
137136 }
138137 }
0 commit comments