What is the best way to save user preferences and files (binary data which is too large to be stored in .plist's)?
I use the following code to save a file:
Though with doesn't work on some Macs (not depending on the Mac OS X version).
Is there a more elegant and correct way to do this? I belive there is.
Please suggest.
I use the following code to save a file:
Code:
char full_filename[50];
FILE *F;
// fopen doesn't understand the ~ symbol in path, so the path needs to be formed manually
sprintf(full_filename, "%s/Library/MyProgramName/filename.ext", getpwnam(getlogin())->pw_dir);
F = fopen(full_filename, "w");
// if fopen fails, probably there's no such folder
if (!F)
{
// create the folder
system("mkdir ~/Library/MyProgramName");
// and try again
F = fopen(full_filename, "w");
}
if (F)
{
// load the data with fread calls
}
fclose(F);
Though with doesn't work on some Macs (not depending on the Mac OS X version).
Is there a more elegant and correct way to do this? I belive there is.
Please suggest.