#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);
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());
}
}