From b16e59b91c3f1ab825f3d1db35b470df843643b8 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 26 Sep 2015 14:26:44 -0400 Subject: [PATCH] Check for existence of save folder before attempting to log events cur_savegame.save_dir can be populated when the save directory does not yet exist after world generation (since the game can be aborted at that stage without saving). --- library/Core.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index c1c1c850a..97192b000 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1975,12 +1975,14 @@ void Core::onStateChange(color_ostream &out, state_change_event event) case SC_MAP_UNLOADED: if (world && world->cur_savegame.save_dir.size()) { - std::string evtlogpath = "data/save/" + world->cur_savegame.save_dir + "/events-dfhack.log"; + std::string save_dir = "data/save/" + world->cur_savegame.save_dir; + std::string evtlogpath = save_dir + "/events-dfhack.log"; std::ofstream evtlog; evtlog.open(evtlogpath, std::ios_base::app); // append if (evtlog.fail()) { - out.printerr("Could not append to %s\n", evtlogpath.c_str()); + if (DFHack::Filesystem::isdir(save_dir)) + out.printerr("Could not append to %s\n", evtlogpath.c_str()); } else {