File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,19 @@ public struct RelativePath: Hashable {
254
254
/// normalization or canonicalization. This will construct a path without
255
255
/// an anchor and thus may be invalid.
256
256
fileprivate init ( unsafeUncheckedPath string: String ) {
257
- self . init ( PathImpl ( string: string) )
257
+ if string. isEmpty {
258
+ self . init ( PathImpl ( string: string) )
259
+ } else {
260
+ #if _runtime(_ObjC)
261
+ let normalized : [ Int8 ] = string. fileSystemRepresentation
262
+ self . init ( PathImpl ( string: String ( cString: normalized) ) )
263
+ #else
264
+ let normalized : UnsafePointer < Int8 > = string. fileSystemRepresentation
265
+ defer { normalized. deallocate ( ) }
266
+
267
+ self . init ( PathImpl ( string: String ( cString: normalized) ) )
268
+ #endif
269
+ }
258
270
}
259
271
260
272
/// Initializes the RelativePath from `str`, which must be a relative path
You can’t perform that action at this time.
0 commit comments