steven_bryant
asked on
How Do I Access user data folder on mac using carbon
I am trying to get path to user data in C++ with carbon.
The path is /Users/{username}/Library/ Applicatio n Support
I have seen code like
FSRef fsRef;
char szPath[1024];
OSErr tError = noErr;
tError = FSFindFolder(kOnAppropriat eDisk,kPre ferenceFol derType,kD ontCreateF older,&fsR ef);
tError = FSRefMakePath(&fsRef,(UInt 8*)path,10 24);
However since I am writing cross-application plug-in for adobe application, I will not have a mac to test on for another couple of days. Can someone verify code that would work for me.
The path is /Users/{username}/Library/
I have seen code like
FSRef fsRef;
char szPath[1024];
OSErr tError = noErr;
tError = FSFindFolder(kOnAppropriat
tError = FSRefMakePath(&fsRef,(UInt
However since I am writing cross-application plug-in for adobe application, I will not have a mac to test on for another couple of days. Can someone verify code that would work for me.
ASKER
Thanks pgnatyuk for your comment.
I just copied and pasted code without really inspecting too much.
However is FSFindFolde carbon?
Also would it be possible to test the code and rewrite it, since I can't test at this time
I just copied and pasted code without really inspecting too much.
However is FSFindFolde carbon?
Also would it be possible to test the code and rewrite it, since I can't test at this time
I re-read your question again and see: "The path is /Users/{username}/Library/ Applicatio n Support". So I do understand more or less what you need.
Yes, it is Carbon. I'll check it.
Yes, it is Carbon. I'll check it.
ASKER
Here is another piece of code I received on Adobe forum http://forums.adobe.com/message/2729174#2729174
FSRef yourUserFolderRef;
OSErr err = FSFindFolder(kUserDomain, kCurrentUserFolderType, kDontCreateFolder, &yourUserFolderRef);
CFURLRef fURL = CFURLCreateFromFSRef(kCFAl locatorDef ault, &yourUserFolderRef);
CFURLRef fHomeURL = CFURLCreateCopyAppendingPa thComponen t(kCFAlloc atorDefaul t, fURL, CFSTR("Library/Application Support"), true);
CFRelease(fURL);
CFStringRef fHFSPath = CFURLCopyFileSystemPath(fH omeURL, kCFURLHFSPathStyle);
What do you think about it?
FSRef yourUserFolderRef;
OSErr err = FSFindFolder(kUserDomain, kCurrentUserFolderType, kDontCreateFolder, &yourUserFolderRef);
CFURLRef fURL = CFURLCreateFromFSRef(kCFAl
CFURLRef fHomeURL = CFURLCreateCopyAppendingPa
CFRelease(fURL);
CFStringRef fHFSPath = CFURLCopyFileSystemPath(fH
What do you think about it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You last comment is about the same - simply another folder. I've posted a link where all this stuff is explained.
http://www.cocoadev.com/index.pl?ApplicationSupportFolder
http://www.cocoadev.com/index.pl?ApplicationSupportFolder
ASKER
However, I have not tested it yet at this time, but it looks goof
ASKER
what is the #include for core foundation framework
In Xcode you simple add a framework. Through popup menu. Or -framework CoreServices to the compile and lnk flags.
ASKER
Thanks. Please excuse my total mac ineptness. I imagine that the plugin project will already include that, but if i'm stuck i'll holler back. Thanks for your help.
ASKER
One more question. Will this work with Unicode string. Lets say username is non-english. Am I getting back a unicode or at least UTF8 string?
I work more with Cocoa than with Carbon. I do not understand why you need Carbon. The latest Xcode even does not have these project templates. Everything works fine in Cocoa. NSString covers all these Unicode problems.
ASKER
I'm kind of confused myself. But I think the indesign sdk which uses c++ needs carbon code.
Could you give me cocoa sample that I can test to see if it works
Could you give me cocoa sample that I can test to see if it works
If your carbon code works, leave it as it is. Inside a cocoa project (objective-c) you can use c, c++, etc
Usually it looks like:
myOSStatus = FSFindFolder(kUserDomain,k
In the next line:
tError = FSRefMakePath(&fsRef,(UInt
'path' - what is this? Probably you wanted to declare
unsigned char path[260]?
Do you need to get to your bundle?
Here you will find many examples and the last one is similar to yours.
http://www.cocoadev.com/index.pl?ApplicationSupportFolder