【发布时间】:2019-07-09 10:15:29
【问题描述】:
在尝试建议的方法here 时,工作目录会得到前缀而不是路径转换。前导: 是HFS 路径没有任何区别。
NSString * ttt = @"Macintosh HD:Users:gautam:code:Help:";
if (CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)ttt, kCFURLPOSIXPathStyle, false))
{
NSString * posixPath = [(__bridge NSURL*)url path];
// posixPath __NSCFString * "/Users/gautamjha/code/Macintosh HD:Users:gautam:code:Help:"
const char * secondName = [posixPath UTF8String];
// above does not help either working directory gets prefixed.
}
【问题讨论】:
-
问题已在引用的问答中解决,只是你没有正确复制代码。
标签: objective-c