The “reverse” operation of CFURLCopyFileSystemPath()
is CFURLCreateWithFileSystemPath()
. Similarly as in the referenced Q&A, you have create the path style from the raw enumeration value since CFURLPathStyle.cfurlhfsPathStyle
is deprecated and not available. Example:
let hfsPath = "Macintosh HD:Applications:Xcode.app"
if let url = CFURLCreateWithFileSystemPath(nil, hfsPath as CFString,
CFURLPathStyle(rawValue: 1)!, true) as URL? {
print(url.path) // /Applications/Xcode.app
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…