0
如果我创建一个URL一拉:尾随斜线重要,但剥离?
const UInt8 *pFilepath = (const UInt8 *)[[NSHomeDirectory() stringByAppendingString:@"/Documents/"] UTF8String];
CFURLRef ldestination = CFURLCreateFromFileSystemRepresentation (NULL, pFilepath, strlen((const char*)pFilepath), false);
,然后记录它,看看我有一拉:
NSLog(@"destination url:%@",(NSString*)ldestination);
在结尾的斜线“/文件/”被删除。如果不重要,不是问题。但是当我做
dirPath = CFURLHasDirectoryPath(ldestination);
if (!dirPath) {
fprintf(stderr, "no dice");
return false;
}
错误被抛出。相反,如果我通过一个NSString,其中包括最后的斜线,它没有错误的CFURLHasDirectoryPath,但不会通过一个
writeStream = CFWriteStreamCreateWithFile(kCFAllocatorDefault, ldestination);
assert(writeStream != NULL);
和Idea这是怎么回事?理想情况下,我认为如果我可以在CFURLRef上保留斜线,它会通过错误,但我确实不知道。
有什么想法?
谢谢。
不知道。谢谢! – 2010-02-19 05:35:30