void ch_save(const char *args)
{
- std::string map_path = Folders::getUserDataPath() + "/Maps/" + args;
+ std::string map_path = Folders::getUserDataPath() + "/Maps";
+ Folders::makeDirectory(map_path);
+ map_path = map_path + "/" + args;
int mapvers = 12;
FILE *tfile;
tfile = fopen( map_path.c_str(), "wb" );
+ if (tfile == NULL) {
+ perror((std::string("Couldn't open file ") + map_path + " for saving").c_str());
+ return;
+ }
fpackf(tfile, "Bi", mapvers);
fpackf(tfile, "Bi", maptype);
fpackf(tfile, "Bi", hostile);
struct FileNotFoundException: public std::exception
{
std::string errorText;
-
+
FileNotFoundException (const std::string& filename)
: errorText(filename + " could not be found")
{}
static inline std::string getUserSavePath()
{ return getUserDataPath() + "/users"; }
+ static bool makeDirectory(const std::string& path);
+
private:
static const char* getHomeDirectory();
static std::string getGenericDirectory(const char* ENVVAR, const std::string& fallback);
- static bool makeDirectory(const std::string& path);
};
#endif /* _FOLDERS_H_ */