Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2007



Tip: Looking for answers? Try searching our database.

user app data directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mlabs - 25 Sep 2007 05:27 GMT
where is the recommended place for a mac application to store user-
specific data and files? Which API do I use to determine the path from
a c++ app ?

TIA
David Phillip Oster - 25 Sep 2007 07:14 GMT
> where is the recommended place for a mac application to store user-
> specific data and files? Which API do I use to determine the path from
> a c++ app ?

If the user is opening and saving them, then on first launch, you might
default to ~/Documents. After that, let the open and save dialog boxes
keep track of the history of recently used folders.

For auxiliary files, ~/Library/Application Support/ is the place. Most
conies make a sub folder in there and put their application's stuff in
the subfolder.

APIs: from C++, you can use either Carbon or Cocoa, but Carbon is
easiest.

Use the FSFindFolder(kLocalDomain,  kApplicationSupportFolderType, TRUE,
&fsRef); system call to get an FSRef, then use FSRefMakePath() from
Files.h to get a full path. That way, you won't have to worry of the
user runs your app on a non-English system.

FSRef fsRef = {0};
char path[2048] = {0};
if(noErr == FSFindFolder(kLocalDomain,  kApplicationSupportFolderType,
TRUE, &fsRef) &&
noErr == FSRefMakePath(&fsRef, (UInt8*)path, sizeof path)) {

  // path is initialized here.
}
Ben Artin - 26 Sep 2007 15:36 GMT
> > where is the recommended place for a mac application to store user-
> > specific data and files? Which API do I use to determine the path from
> > a c++ app ?

[...]

> Use the FSFindFolder(kLocalDomain,  kApplicationSupportFolderType, TRUE,
> &fsRef); system call to get an FSRef, then use FSRefMakePath() from
> Files.h to get a full path. That way, you won't have to worry of the
> user runs your app on a non-English system.

kLocalDomain is wrong for user-specific files, you meant kUserDomain.

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

David Phillip Oster - 27 Sep 2007 04:01 GMT
> > Use the FSFindFolder(kLocalDomain,  kApplicationSupportFolderType, TRUE,
> > &fsRef);
>
> kLocalDomain is wrong for user-specific files, you meant kUserDomain.

oops. Thank you. I'm sure you are right.
mlabs - 30 Sep 2007 02:08 GMT
what do I link to in my makefile if i'm usinf FSFindFolder?  in
general, how do you figure this out? the apple docs usually specify a
header but no lib...
Michael Ash - 30 Sep 2007 02:29 GMT
> what do I link to in my makefile if i'm usinf FSFindFolder?  in
> general, how do you figure this out? the apple docs usually specify a
> header but no lib...

Go to the top of the Folder Manager Reference, which is the page which
contains the FSFindFolder document. There you will see that it resides in
the CoreServices framework. So add -framework CoreServices to your compile
and link flags.

Signature

Michael Ash
Rogue Amoeba Software

Reinder Verlinde - 25 Sep 2007 18:59 GMT
> where is the recommended place for a mac application to store user-
> specific data and files?

<http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/
index.html>

> Which API do I use to determine the path from
> > a c++ app ?

<http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/
Articles/Domains.html#//apple_ref/doc/uid/20002281-101591-BAJCBACI>

Reinder
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.