Skip to content

Commit fb55cd4

Browse files
authored
Merge pull request #2014 from compnerd/bringing-whack-back-into-style
2 parents 74b714a + b84647f commit fb55cd4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Foundation/NSURL.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ internal let kCFURLPOSIXPathStyle = CFURLPathStyle.cfurlposixPathStyle
1515
internal let kCFURLWindowsPathStyle = CFURLPathStyle.cfurlWindowsPathStyle
1616
#endif
1717

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+
1825
private func _standardizedPath(_ path: String) -> String {
1926
if !path.absolutePath {
2027
return path._nsObject.standardizingPath
@@ -298,9 +305,9 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
298305
let thePath = _standardizedPath(path)
299306
if thePath.length > 0 {
300307

301-
_CFURLInitWithFileSystemPathRelativeToBase(_cfObject, thePath._cfObject, kCFURLPOSIXPathStyle, isDir, baseURL?._cfObject)
308+
_CFURLInitWithFileSystemPathRelativeToBase(_cfObject, thePath._cfObject, kCFURLPlatformPathStyle, isDir, baseURL?._cfObject)
302309
} 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)
304311
}
305312
}
306313

@@ -347,7 +354,7 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
347354
}
348355
}
349356
super.init()
350-
_CFURLInitWithFileSystemPathRelativeToBase(_cfObject, thePath._cfObject, kCFURLPOSIXPathStyle, isDir.boolValue, nil)
357+
_CFURLInitWithFileSystemPathRelativeToBase(_cfObject, thePath._cfObject, kCFURLPlatformPathStyle, isDir.boolValue, nil)
351358
}
352359

353360
public convenience init(fileURLWithFileSystemRepresentation path: UnsafePointer<Int8>, isDirectory isDir: Bool, relativeTo baseURL: URL?) {
@@ -517,7 +524,7 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
517524

518525
open var path: String? {
519526
let absURL = CFURLCopyAbsoluteURL(_cfObject)
520-
return CFURLCopyFileSystemPath(absURL, kCFURLPOSIXPathStyle)?._swiftObject
527+
return CFURLCopyFileSystemPath(absURL, kCFURLPlatformPathStyle)?._swiftObject
521528
}
522529

523530
open var fragment: String? {
@@ -534,7 +541,7 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
534541

535542
// The same as path if baseURL is nil
536543
open var relativePath: String? {
537-
return CFURLCopyFileSystemPath(_cfObject, kCFURLPOSIXPathStyle)?._swiftObject
544+
return CFURLCopyFileSystemPath(_cfObject, kCFURLPlatformPathStyle)?._swiftObject
538545
}
539546

540547
/* 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

Comments
 (0)