@@ -15,6 +15,13 @@ internal let kCFURLPOSIXPathStyle = CFURLPathStyle.cfurlposixPathStyle
15
15
internal let kCFURLWindowsPathStyle = CFURLPathStyle . cfurlWindowsPathStyle
16
16
#endif
17
17
18
+ // NOTE: this represents PLATFORM_PATH_STYLE
19
+ #if os(Windows)
20
+ internal let kCFURLPlatformPathStyle = kCFURLWindowsPathStyle
21
+ #else
22
+ internal let kCFURLPlatformPathStyle = kCFURLPOSIXPathStyle
23
+ #endif
24
+
18
25
private func _standardizedPath( _ path: String ) -> String {
19
26
if !path. absolutePath {
20
27
return path. _nsObject. standardizingPath
@@ -298,9 +305,9 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
298
305
let thePath = _standardizedPath ( path)
299
306
if thePath. length > 0 {
300
307
301
- _CFURLInitWithFileSystemPathRelativeToBase ( _cfObject, thePath. _cfObject, kCFURLPOSIXPathStyle , isDir, baseURL? . _cfObject)
308
+ _CFURLInitWithFileSystemPathRelativeToBase ( _cfObject, thePath. _cfObject, kCFURLPlatformPathStyle , isDir, baseURL? . _cfObject)
302
309
} else if let baseURL = baseURL {
303
- _CFURLInitWithFileSystemPathRelativeToBase ( _cfObject, baseURL. path. _cfObject, kCFURLPOSIXPathStyle , baseURL. hasDirectoryPath, nil )
310
+ _CFURLInitWithFileSystemPathRelativeToBase ( _cfObject, baseURL. path. _cfObject, kCFURLPlatformPathStyle , baseURL. hasDirectoryPath, nil )
304
311
}
305
312
}
306
313
@@ -347,7 +354,7 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
347
354
}
348
355
}
349
356
super. init ( )
350
- _CFURLInitWithFileSystemPathRelativeToBase ( _cfObject, thePath. _cfObject, kCFURLPOSIXPathStyle , isDir. boolValue, nil )
357
+ _CFURLInitWithFileSystemPathRelativeToBase ( _cfObject, thePath. _cfObject, kCFURLPlatformPathStyle , isDir. boolValue, nil )
351
358
}
352
359
353
360
public convenience init ( fileURLWithFileSystemRepresentation path: UnsafePointer < Int8 > , isDirectory isDir: Bool , relativeTo baseURL: URL ? ) {
@@ -517,7 +524,7 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
517
524
518
525
open var path : String ? {
519
526
let absURL = CFURLCopyAbsoluteURL ( _cfObject)
520
- return CFURLCopyFileSystemPath ( absURL, kCFURLPOSIXPathStyle ) ? . _swiftObject
527
+ return CFURLCopyFileSystemPath ( absURL, kCFURLPlatformPathStyle ) ? . _swiftObject
521
528
}
522
529
523
530
open var fragment : String ? {
@@ -534,7 +541,7 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
534
541
535
542
// The same as path if baseURL is nil
536
543
open var relativePath : String ? {
537
- return CFURLCopyFileSystemPath ( _cfObject, kCFURLPOSIXPathStyle ) ? . _swiftObject
544
+ return CFURLCopyFileSystemPath ( _cfObject, kCFURLPlatformPathStyle ) ? . _swiftObject
538
545
}
539
546
540
547
/* Determines if a given URL string's path represents a directory (i.e. the path component in the URL string ends with a '/' character). This does not check the resource the URL refers to.
0 commit comments