#include <fstream>
#include "MacCompatibility.h"
#include "string.h"
+#include <iostream>
using namespace std;
FILE *tfile;
int numaccounts;
int accountactive;
+ errno = 0;
- tfile = fopen(ConvertFileName(filename.c_str()), "rb" );
+ tfile = fopen(filename.c_str(), "rb" );
if (tfile) {
funpackf(tfile, "Bi", &numaccounts);
funpackf(tfile, "Bi", &(acc->progress));
int nbCampaigns;
funpackf(tfile, "Bi", &nbCampaigns);
- //~ printf("loading %d campaign progress info\n",nbCampaigns);
for (int k = 0; k < nbCampaigns; ++k) {
string campaignName = "";
funpackf(tfile, "Bb", &c);
campaignName.append(1, c);
}
- //~ printf("loading %s campaign progress info\n",campaignName.c_str());
funpackf(tfile, "Bf", &(acc->campaignProgress[campaignName].time));
funpackf(tfile, "Bf", &(acc->campaignProgress[campaignName].score));
funpackf(tfile, "Bf", &(acc->campaignProgress[campaignName].fasttime));
fclose(tfile);
return get(accountactive);
} else {
- printf("filenotfound\n");
+ perror(("Couldn't load users from " + filename).c_str());
return NULL;
}
}
void Account::saveFile(string filename, Account* accountactive)
{
FILE *tfile;
+ errno = 0;
- tfile = fopen(ConvertFileName(filename.c_str(), "wb"), "wb" );
+ tfile = fopen(filename.c_str(), "wb" );
if (tfile) {
printf("writing %d accounts :\n", getNbAccounts());
fpackf(tfile, "Bi", getNbAccounts());
}
fclose(tfile);
+ } else {
+ perror(("Couldn't save users in " + filename).c_str());
}
}