From ecc1376ad7c91308b79a910d2b393bd64d348373 Mon Sep 17 00:00:00 2001 From: David Kolossa Date: Tue, 5 May 2009 16:41:14 +0200 Subject: [PATCH] Introduced FileSystem and Out classes - These classes can and should now be used anywhere --- src/bbfile.cc | 7 ++- src/defparse/defaction.cc | 142 +++++++++++++++++++++++++----------------- src/eal/irrlicht/scenenode.cc | 3 +- src/entity.cc | 3 +- src/error.cc | 9 +-- src/kingdom.cc | 17 ++--- src/main.cc | 11 +++- src/map.cc | 2 +- src/output.cc | 8 +-- 9 files changed, 120 insertions(+), 82 deletions(-) diff --git a/src/bbfile.cc b/src/bbfile.cc index 1e63404..cf02db5 100644 --- a/src/bbfile.cc +++ b/src/bbfile.cc @@ -25,7 +25,12 @@ BBFile::BBFile (std::string filePath) { - file.open (filePath.c_str(), std::fstream::binary | std::fstream::in | std::fstream::out); + file.open (filePath.c_str(), std::fstream::binary | std::fstream::in | std::fstream::out); + if(!file) + { + // Try again. Read-only... + file.open (filePath.c_str(), std::fstream::binary | std::fstream::in); + } } BBFile::~BBFile () diff --git a/src/defparse/defaction.cc b/src/defparse/defaction.cc index c6395d1..3e6614d 100644 --- a/src/defparse/defaction.cc +++ b/src/defparse/defaction.cc @@ -24,6 +24,8 @@ #include #include #include +#include "../filesystem.hh" +#include "../output.hh" #include "../s2string.hh" #include "../kingdom.hh" #include "../error.hh" @@ -122,15 +124,19 @@ def::IDAction::operator() (std::string rtext) currentType = newID; - if (Kingdom::kingdomList.find (kingdomID) != Kingdom::kingdomList.end ()) - if (!Kingdom::kingdomList[kingdomID]->typeExists(newID)) - Kingdom::kingdomList[kingdomID]->insertType (newID); - else - { - std::cerr << "Fatal: Type #" << newID << " has already been declared!" << std::endl; - } + if (Kingdom::kingdomList.find (kingdomID) != Kingdom::kingdomList.end ()) + { + if (!Kingdom::kingdomList[kingdomID]->typeExists(newID)) + Kingdom::kingdomList[kingdomID]->insertType (newID); else - std::cerr << "Fatal: kingdom does not exist!" << std::endl; + { + Out::fatal << "Type #" << newID << " has already been declared!" << Out::endl; + } + } + else + { + Out::fatal << "Kingdom does not exist!" << Out::endl; + } } @@ -140,14 +146,14 @@ def::NameAction::operator() (std::string rtext) { if (currentType == 0) { - std::cerr << "No type ID specified, assignment of value \"name\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"name\" not possible" << Out::endl; return; } if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setName (rtext); else - std::cerr << "Double assignment of value \"name\" in object type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"name\" in object type #" << currentType << Out::endl; } @@ -157,17 +163,41 @@ def::ModelAction::operator() (std::string rtext) { if (currentType == 0) { - std::cerr << "No type ID specified, assignment of value \"model\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"model\" not possible" << Out::endl; return; } + + // Spot legacy file paths, transform and give a deprecation warning + // Since Stranded II had all files given relative to the mod directory, + // we use the "gfx\" piece to spot legacy file paths + std::string::size_type pos; + if((pos = rtext.find("gfx\\")) != std::string::npos) + { + Out::warning << "Deprecated model file path format in type # " << currentType << Out::endl; + + // Remove old directory part + rtext = rtext.substr(pos+4); + + // Remove file extension + pos = rtext.find_last_of('.'); + rtext = rtext.substr(0, pos); + } + // Remove backslashes for (unsigned int i = 0; i < rtext.size(); i++) if (rtext[i] == '\\') rtext[i] = '/'; if (this->lastType != currentType) - Kingdom::kingdomList[kingdomID]->getType (currentType)->setModel (rtext); + { + FileInfo *modelInfo = FileSystem::getModelFileInfo(rtext); + Kingdom::kingdomList[kingdomID]->getType (currentType)->setModel (modelInfo->path); + delete modelInfo; + } else - std::cerr << "Double assignment of value \"model\" in type #" << currentType << std::endl; + { + Out::warning << "Double assignment of value \"model\" in type #" << currentType << Out::endl; + } + } @@ -176,12 +206,12 @@ void def::IconAction::operator() (std::string rtext) { if (currentType == 0) - std::cerr << "No type ID specified, assignment of value \"icon\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"icon\" not possible" << Out::endl; if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setIconPath (rtext); else - std::cerr << "Double assignment of value \"icon\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"icon\" in type #" << currentType << Out::endl; } @@ -194,20 +224,20 @@ def::XAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"x\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"x\" not possible" << Out::endl; return; } if (newScaleX <= 0) { - std::cerr << "Error: Invalid value \"x\"; fallback to 1.0 in type #" << currentType << std::endl; + Out::warning << "Invalid value \"x\"; fallback to 1.0 in type #" << currentType << Out::endl; newScaleX = 1.0; } if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setScaleX (newScaleX); else - std::cerr << "Error: Double assignment of value \"x\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"x\" in type #" << currentType << Out::endl; } @@ -220,20 +250,20 @@ def::YAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"y\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"y\" not possible" << Out::endl; return; } if (newScaleY <= 0) { - std::cerr << "Error: Invalid value \"y\"; fallback to 1.0 in type #" << currentType << std::endl; + Out::warning << "Invalid value \"y\"; fallback to 1.0 in type #" << currentType << Out::endl; newScaleY = 1.0; } if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setScaleY (newScaleY); else - std::cerr << "Error: Double assignment of value \"y\" in Object type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"y\" in Object type #" << currentType << Out::endl; } @@ -246,20 +276,20 @@ def::ZAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"z\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"z\" not possible" << Out::endl; return; } if (newScaleZ <= 0) { - std::cerr << "Error: Invalid value \"z\"; fallback to 1.0 in type #" << currentType << std::endl; + Out::warning << "Invalid value \"z\"; fallback to 1.0 in type #" << currentType << Out::endl; newScaleZ = 1.0; } if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setScaleZ (newScaleZ); else - std::cerr << "Error: Double assignment of value \"z\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"z\" in type #" << currentType << Out::endl; } @@ -274,7 +304,7 @@ def::ScaleAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"scale\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"scale\" not possible" << Out::endl; return; } @@ -283,7 +313,7 @@ def::ScaleAction::operator() (std::string rtext) // Display error message when number of arguments wasn't either 1 or 3 if (warnFlag != EXPLODE_OK && !inFlag (warnFlag, EXPLODE_NO_TOKEN)) { - std::cerr << "Warning: Wrong number of arguments for value \"scale\"" << std::endl; + Out::warning << "Warning: Wrong number of arguments for value \"scale\"" << Out::endl; } @@ -295,7 +325,7 @@ def::ScaleAction::operator() (std::string rtext) { if (!s2str::stof (scaleValues[0], endValue)) { - std::cerr << "Error: Invalid value in \"scale\"; fallback to 1.0 in type #" << currentType << std::endl; + Out::warning << "Invalid value in \"scale\"; fallback to 1.0 in type #" << currentType << Out::endl; endValue = 1.0; } Kingdom::kingdomList[kingdomID]->getType (currentType) ->setScaleX (endValue); @@ -307,7 +337,7 @@ def::ScaleAction::operator() (std::string rtext) // scaleX if (!s2str::stof (scaleValues[0], endValue)) { - std::cerr << "Error: Invalid x value in \"scale\"; fallback to 1.0 in type #" << currentType << std::endl; + Out::warning << "Invalid x value in \"scale\"; fallback to 1.0 in type #" << currentType << Out::endl; endValue = 1.0; } Kingdom::kingdomList[kingdomID]->getType (currentType) ->setScaleX (endValue); @@ -316,7 +346,7 @@ def::ScaleAction::operator() (std::string rtext) // scaleY if (!s2str::stof (scaleValues[1], endValue)) { - std::cerr << "Error: Invalid y value in \"scale\"; fallback to 1.0 in type #" << currentType << std::endl; + Out::warning << "Invalid y value in \"scale\"; fallback to 1.0 in type #" << currentType << Out::endl; endValue = 1.0; } Kingdom::kingdomList[kingdomID]->getType (currentType) ->setScaleY (endValue); @@ -326,14 +356,14 @@ def::ScaleAction::operator() (std::string rtext) // scaleZ if (!s2str::stof (scaleValues[2], endValue)) { - std::cerr << "Error: Invalid z value in \"scale\"; fallback to 1.0 in type #" << currentType << std::endl; + Out::warning << "Invalid z value in \"scale\"; fallback to 1.0 in type #" << currentType << Out::endl; endValue = 1.0; } Kingdom::kingdomList[kingdomID]->getType (currentType) ->setScaleZ (endValue); } else { - std::cerr << "Error: Double assignment of value \"scale\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"scale\" in type #" << currentType << Out::endl; } } @@ -347,21 +377,21 @@ def::RAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"r\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"r\" not possible" << Out::endl; return; } strValid = s2str::stoi (rtext, newColorR); if (!strValid || newColorR < 0 || newColorR > 255) { - std::cerr << "Error: Invalid argument for \"r\" value in type #" << currentType << ", fallback to 0" << std::endl; + Out::warning << "Invalid argument for \"r\" value in type #" << currentType << ", fallback to 0" << Out::endl; newColorR = 0; } if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setColorR ( (uint8_t) newColorR); else - std::cerr << "Error: Double assignment of value \"r\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"r\" in type #" << currentType << Out::endl; } @@ -374,21 +404,21 @@ def::GAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"g\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"g\" not possible" << Out::endl; return; } strValid = s2str::stoi (rtext, newColorG); if (!strValid || newColorG < 0 || newColorG > 255) { - std::cerr << "Error: Invalid argument for \"g\" value in type #" << currentType << ", fallback to 0" << std::endl; + Out::warning << "Invalid argument for \"g\" value in type #" << currentType << ", fallback to 0" << Out::endl; newColorG = 0; } if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setColorG ( (uint8_t) newColorG); else - std::cerr << "Error: Double assignment of value \"g\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"g\" in type #" << currentType << Out::endl; } @@ -401,21 +431,21 @@ def::BAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"b\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"b\" not possible" << Out::endl; return; } strValid = s2str::stoi (rtext, newColorB); if (!strValid || newColorB < 0 || newColorB > 255) { - std::cerr << "Error: Invalid argument for \"b\" value in type #" << currentType << ", fallback to 0" << std::endl; + Out::warning << "Invalid argument for \"b\" value in type #" << currentType << ", fallback to 0" << Out::endl; newColorB = 0; } if (this->lastType != currentType) Kingdom::kingdomList[kingdomID]->getType (currentType) ->setColorB ( (uint8_t) newColorB); else - std::cerr << "Error: Double assignment of value \"b\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"b\" in type #" << currentType << Out::endl; } @@ -430,7 +460,7 @@ def::ColorAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type ID specified, assignment of value \"color\" not possible" << std::endl; + Out::warning << "No type ID specified, assignment of value \"color\" not possible" << Out::endl; return; } @@ -439,7 +469,7 @@ def::ColorAction::operator() (std::string rtext) // Display error message when number of arguments wasn't either 1 or 3 if (warnFlag != EXPLODE_OK && !inFlag (warnFlag, EXPLODE_NO_TOKEN)) { - std::cerr << "Warning: Wrong number of arguments for value \"color\"" << std::endl; + Out::warning << "Warning: Wrong number of arguments for value \"color\"" << Out::endl; } if (this->lastType != currentType) @@ -451,7 +481,7 @@ def::ColorAction::operator() (std::string rtext) strValid = s2str::stoi (colorValues[0], endValue); if (!strValid || endValue < 0 || endValue > 255) { - std::cerr << "Error: Invalid value in \"color\"; fallback to 0.0 in type #" << currentType << std::endl; + Out::warning << "Invalid value in \"color\"; fallback to 0.0 in type #" << currentType << Out::endl; endValue = 0; } Kingdom::kingdomList[kingdomID]->getType (currentType) ->setColorR (endValue); @@ -464,7 +494,7 @@ def::ColorAction::operator() (std::string rtext) strValid = s2str::stoi (colorValues[0], endValue); if (!strValid || endValue < 0 || endValue > 255) { - std::cerr << "Error: Invalid argument for \"r\" value in \"color\" in type #" << currentType << ", fallback to 0" << std::endl; + Out::warning << "Invalid argument for \"r\" value in \"color\" in type #" << currentType << ", fallback to 0" << Out::endl; endValue = 0; } @@ -475,7 +505,7 @@ def::ColorAction::operator() (std::string rtext) strValid = s2str::stoi (colorValues[1], endValue); if (!strValid || endValue < 0 || endValue > 255) { - std::cerr << "Error: Invalid argument for \"g\" value in \"color\" in type #" << currentType << ", fallback to 0" << std::endl; + Out::warning << "Invalid argument for \"g\" value in \"color\" in type #" << currentType << ", fallback to 0" << Out::endl; endValue = 0; } @@ -486,7 +516,7 @@ def::ColorAction::operator() (std::string rtext) strValid = s2str::stoi (colorValues[2], endValue); if (!strValid || endValue > 255) { - std::cerr << "Error: Invalid argument for \"b\" value in \"color\" in type #" << currentType << ", fallback to 0" << std::endl; + Out::warning << "Invalid argument for \"b\" value in \"color\" in type #" << currentType << ", fallback to 0" << Out::endl; endValue = 0; } @@ -495,7 +525,7 @@ def::ColorAction::operator() (std::string rtext) } else { - std::cerr << "Error: Double assignment of value \"color\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"color\" in type #" << currentType << Out::endl; } } @@ -508,7 +538,7 @@ def::AutofadeAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type id specified, assignment of value \"autofade\" not possible" << std::endl; + Out::warning << "No type id specified, assignment of value \"autofade\" not possible" << Out::endl; return; } @@ -516,7 +546,7 @@ def::AutofadeAction::operator() (std::string rtext) { if (!s2str::stof (rtext, endValue)) { - std::cerr << "Error: Invalid argument for value \"autofade\" in type #" << currentType << ", fallback to 500" << std::endl; + Out::warning << "Invalid argument for value \"autofade\" in type #" << currentType << ", fallback to 500" << Out::endl; endValue = 500.0; } @@ -524,7 +554,7 @@ def::AutofadeAction::operator() (std::string rtext) } else { - std::cerr << "Error: Double assignment of value \"autofade\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"autofade\" in type #" << currentType << Out::endl; } } @@ -537,7 +567,7 @@ def::AlphaAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type id specified, assignment of value \"alpha\" not possible" << std::endl; + Out::warning << "No type id specified, assignment of value \"alpha\" not possible" << Out::endl; return; } @@ -545,7 +575,7 @@ def::AlphaAction::operator() (std::string rtext) { if (!s2str::stof (rtext, endValue) || endValue < 0.0 || endValue > 1.0) { - std::cerr << "Error: Invalid argument for value \"alpha\" in type #" << currentType << ", fallback to 1.0" << std::endl; + Out::warning << "Invalid argument for value \"alpha\" in type #" << currentType << ", fallback to 1.0" << Out::endl; endValue = 1.0; } @@ -553,7 +583,7 @@ def::AlphaAction::operator() (std::string rtext) } else { - std::cerr << "Error: Double assignment of value \"alpha\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"alpha\" in type #" << currentType << Out::endl; } } @@ -566,7 +596,7 @@ def::ShineAction::operator() (std::string rtext) if (currentType == 0) { - std::cerr << "Error: No type id specified, assignment of value \"shine\" not possible" << std::endl; + Out::warning << "No type id specified, assignment of value \"shine\" not possible" << Out::endl; return; } @@ -574,7 +604,7 @@ def::ShineAction::operator() (std::string rtext) { if (!s2str::stof (rtext, endValue) || endValue < 0.0 || endValue > 1.0) { - std::cerr << "Error: Invalid argument for value \"shine\" in type #" << currentType << ", fallback to 0.0" << std::endl; + Out::warning << "Invalid argument for value \"shine\" in type #" << currentType << ", fallback to 0.0" << Out::endl; endValue = 0.0; } @@ -582,6 +612,6 @@ def::ShineAction::operator() (std::string rtext) } else { - std::cerr << "Error: Double assignment of value \"shine\" in type #" << currentType << std::endl; + Out::warning << "Double assignment of value \"shine\" in type #" << currentType << Out::endl; } } diff --git a/src/eal/irrlicht/scenenode.cc b/src/eal/irrlicht/scenenode.cc index 0a593cb..0c0c038 100644 --- a/src/eal/irrlicht/scenenode.cc +++ b/src/eal/irrlicht/scenenode.cc @@ -52,8 +52,7 @@ namespace eal node->remove(); // Create new scene node scene::ISceneManager *smgr = ((IrrlichtEngine*)Engine::get())->getSceneManager(); - scene::IAnimatedMesh *mesh = smgr->getMesh((std::string("mods/") - + Engine::get()->getSettings()->getModName() + "/" + model).c_str()); + scene::IAnimatedMesh *mesh = smgr->getMesh(model.c_str()); node = smgr->addAnimatedMeshSceneNode(mesh); } diff --git a/src/entity.cc b/src/entity.cc index dfe0de1..7c3e5f7 100644 --- a/src/entity.cc +++ b/src/entity.cc @@ -19,6 +19,7 @@ * along with OpenStranded. If not, see . */ +#include "output.hh" #include "entity.hh" #include "kingdom.hh" #include "eal/engine.hh" @@ -30,7 +31,7 @@ Entity::Entity (ID type): void Entity::load(Type *type) { - printf("Entity: %s\n", type->getName().c_str()); + Out::msg.printf("Entity: %s\n", type->getName().c_str()); std::string model = type->getModel(); if (model != "") { diff --git a/src/error.cc b/src/error.cc index aa7f4a7..66abb01 100644 --- a/src/error.cc +++ b/src/error.cc @@ -1,5 +1,6 @@ #include #include +#include "output.hh" #include "error.hh" StrandedException::StrandedException (const char* m) @@ -24,7 +25,7 @@ StrandedException::what () throw () void StrandedException::print () { - std::cout << "StrandedException: " << this->what () << std::endl; + Out::msg << "StrandedException: " << this->what () << Out::endl; } @@ -57,17 +58,17 @@ StrandedException (m) {} void StrandedWarning::print () { - std::cout << "StrandedWarning: " << this->what () << std::endl; + Out::warning << this->what () << Out::endl; } void StrandedError::print () { - std::cout << "StrandedError: " << this->what () << std::endl; + Out::error << this->what () << Out::endl; } void StrandedFatal::print () { - std::cout << "StrandedFatal: " << this->what () << std::endl; + Out::msg << this->what () << Out::endl; } diff --git a/src/kingdom.cc b/src/kingdom.cc index 0b77c8f..a09ec47 100644 --- a/src/kingdom.cc +++ b/src/kingdom.cc @@ -19,6 +19,7 @@ * along with OpenStranded. If not, see . */ +#include "output.hh" #include "kingdom.hh" #include "object.hh" #include "unit.hh" @@ -28,13 +29,13 @@ #include #ifdef unix -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include #else -#include + #include #endif @@ -212,7 +213,7 @@ Kingdom::parseEntityTypes(std::string mod, std::string name) int file = open(filename.c_str(), O_RDONLY); if (!file) { - printf("Could not open file \"%s\".\n", filename.c_str()); + Out::msg.printf("Could not open file \"%s\".\n", filename.c_str()); continue; } struct stat stat; @@ -224,7 +225,7 @@ Kingdom::parseEntityTypes(std::string mod, std::string name) if (!strncmp(dirent->d_name, name.c_str(), strlen(name.c_str())) && !strcmp(dirent->d_name + strlen(dirent->d_name) - 4, ".inf")) { - printf("Parsing %s\n", filename.c_str()); + Out::msg.printf("Parsing %s\n", filename.c_str()); def::object::parse(filename.c_str()); } } diff --git a/src/main.cc b/src/main.cc index 18fc788..3114356 100644 --- a/src/main.cc +++ b/src/main.cc @@ -23,6 +23,8 @@ main (int argc, char **argv) { mod = argv[1]; } + FileSystem::setModName(mod); + // Setup core services Out::setConsoleFlags(Out::FATAL | Out::ERROR | Out::WARNING | Out::DEBUG); Out::setLoggingFlags(Out::NONE); @@ -31,10 +33,8 @@ main (int argc, char **argv) GlobalSettings settings("settings.cfg"); settings.readConfigFile(); settings.setModName(mod); - FileSystem::setModName(mod); try { - Kingdom::initKingdomList(mod); // Start engine std::string renderer = settings.getRenderer(); #if !defined(HAVE_IRRLICHT) && defined(HAVE_HORDE3D) @@ -60,9 +60,14 @@ main (int argc, char **argv) } if (!engine) throw std::string("No renderer available!"); + + Kingdom::initKingdomList(mod); + engine->init(&settings); // Load map - std::string filename = std::string("mods/") + mod + "/maps/adventure/map02.s2"; + FileInfo *mapFileInfo = FileSystem::getMapFileInfo("adventure/map02"); + std::string filename = mapFileInfo->path; + delete mapFileInfo; Map map; map.load(filename); while (true) diff --git a/src/map.cc b/src/map.cc index 5c07a24..aa31206 100644 --- a/src/map.cc +++ b/src/map.cc @@ -43,7 +43,7 @@ Map::load (std::string path) BBFile mapfile(path); if (!mapfile) { - std::cerr << "Map file couldn't be opened!" << std::endl; + std::cerr << "Map file couldn't be opened: " << path << std::endl; return false; } diff --git a/src/output.cc b/src/output.cc index 7a6699c..d4589bc 100644 --- a/src/output.cc +++ b/src/output.cc @@ -35,6 +35,7 @@ #endif #include +#include "filesystem.hh" #include "output.hh" // This constant is used for allocating memory in Printer::printf @@ -227,12 +228,7 @@ Out::setLogFile(std::string fileName) path += "/.openstranded/"; if(opendir(path.c_str()) == NULL) { - int dirCreated = mkdir(path.c_str(), S_IRWXU); - if(dirCreated != 0) - { - std::cerr << "FATAL: OpenStranded dir couldn't be created" << std::endl; - return; - } + FileSystem::initUserDirectory(); } #else -- 2.11.4.GIT