Si j'enregistrer des fichiers à l'intérieur du paquet .app
, il sauve OK, mais Apple recommande l'enregistrement des fichiers à l'intérieur du support d'application sousC++ MAC OS X ne peut pas écrire ~/Library/Application Support/<appname>
~/Library/Application Support/appname
ou J'ai essayé les deux, mais je reçois toujours une exception. Je reçois un chemin vers le support d'application, qui est
/Users/myname/Library/Application Support/com.company.appname/
ou
/Users/myname/Library/Application Support/AppName/
com.company.appname
est correctement spécifié dans mon info.plist
et AppName
est product AppName.app
, de sorte que les chemins semble correct.
{
FilepathProcessor::pathForFile(fpath, "menustate", ".sav",
PATH_TO_DESTINATION_SAVE_LOAD_FOLDER);
std::ofstream file;
file.exceptions(std::ofstream::eofbit | std::ofstream::failbit |
std::ofstream::badbit);
INFO_ARG("prepare to save to '%s'", fpath.c_str());
try {
file.open(fpath.c_str(), std::ios::out | std::ios::binary |
std::ios::trunc);
ERROR_IF_ARG(!file.is_open(), "couldnt open file for saving at '%s'",
fpath.c_str(), return);
//will pass this point
//exception happens by first write
WRITE_INT_TO_BINFILE(file, episode);
//...
}
catch (std::ofstream::failure e) {
ERROR_IF_ARG(true, "exception %s", e.what(), return);
}
file.close();
}
Sortie:
INFO : prepare to save to '/Users/myname/Library/Application
Support/com.comapny.appname/menustate.sav' [CALLED BY : saveToFile]
ERROR!
Text : exception basic_ios::clear