Saving CFPropertyLists To Users Folder

Posted by stephen blinkhorn on Stack Overflow See other posts from Stack Overflow or by stephen blinkhorn
Published on 2010-03-17T05:26:24Z Indexed on 2010/03/17 5:31 UTC
Read the original article Hit count: 253

Filed under:
|
|
|

I'm trying to save a CFPropertyList to a location in the user's home folder. Using the code below I'm getting errorCode = -10 (unknown error).

CFURLRef fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("~/testfile.txt"),  kCFURLPOSIXPathStyle, false );  

SInt32 errorCode;
Boolean status = CFURLWriteDataAndPropertiesToResource(fileURL, xmlData, NULL, &errorCode);

If I change the path to something like "/testfile.txt" without the '~' then everything works. How can one save a property list to the current user's home folder? Must one obtain the user's name first and include it in the path such as /users/toffler/testfile.txt?

© Stack Overflow or respective owner

Related posts about mac

Related posts about unix