[colobot] 01/04: Fixed log file creation crash (#755)
Didier Raboud
odyx at moszumanska.debian.org
Fri Apr 8 11:34:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to annotated tag debian/0.1.7b-1
in repository colobot.
commit 37d72351be2f02b90fec5bead671c48e47f418a5
Author: krzys-h <krzys_h at interia.pl>
Date: Sat Apr 2 14:18:34 2016 +0200
Fixed log file creation crash (#755)
---
src/app/main.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/app/main.cpp b/src/app/main.cpp
index de3f842..88908f6 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -44,6 +44,7 @@
#include <memory>
#include <vector>
+#include <boost/filesystem.hpp>
/* Doxygen main page */
@@ -98,13 +99,19 @@ int main(int argc, char *argv[])
systemUtils->Init();
// Add file output to the logger
- std::string logfile;
+ std::string logFileName;
#if DEV_BUILD
- logfile = "log.txt";
+ logFileName = "log.txt";
#else
- logfile = systemUtils->GetSaveDir() + "/log.txt";
+ boost::filesystem::create_directories(systemUtils->GetSaveDir());
+ logFileName = systemUtils->GetSaveDir() + "/log.txt";
#endif
- logger.AddOutput(fopen(logfile.c_str(), "w"));
+ FILE* logFile = fopen(logFileName.c_str(), "w");
+ if (logFile)
+ logger.AddOutput(logFile);
+ else
+ logger.Error("Failed to create log file, writing log to file disabled\n");
+
// Workaround for character encoding in argv on Windows
#if PLATFORM_WINDOWS
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list