+ // make sure the savegame directory exists
+ std::string dirname = FileSystem::dirname(filename);
+ if(!PHYSFS_exists(dirname.c_str())) {
+ if(PHYSFS_mkdir(dirname.c_str())) {
+ std::ostringstream msg;
+ msg << "Couldn't create directory for savegames '"
+ << dirname << "': " <<PHYSFS_getLastError();
+ throw std::runtime_error(msg.str());
+ }
+ }
+
+ if(!PHYSFS_isDirectory(dirname.c_str())) {
+ std::ostringstream msg;
+ msg << "Savegame path '" << dirname << "' is not a directory";
+ throw std::runtime_error(msg.str());
+ }