summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mana.cbp2
-rw-r--r--mana.files2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/client.cpp14
-rw-r--r--src/log.cpp12
6 files changed, 18 insertions, 16 deletions
diff --git a/mana.cbp b/mana.cbp
index 8282351c..82c08cc1 100644
--- a/mana.cbp
+++ b/mana.cbp
@@ -575,6 +575,8 @@
<Unit filename="src\utils\dtor.h" />
<Unit filename="src\utils\gettext.h" />
<Unit filename="src\utils\mathutils.h" />
+ <Unit filename="src\utils\mkdir.cpp" />
+ <Unit filename="src\utils\mkdir.h" />
<Unit filename="src\utils\mutex.h" />
<Unit filename="src\utils\sha256.cpp" />
<Unit filename="src\utils\sha256.h" />
diff --git a/mana.files b/mana.files
index 9551ae31..ed1605b0 100644
--- a/mana.files
+++ b/mana.files
@@ -517,6 +517,8 @@
./src/utils/dtor.h
./src/utils/gettext.h
./src/utils/mathutils.h
+./src/utils/mkdir.cpp
+./src/utils/mkdir.h
./src/utils/mutex.h
./src/utils/sha256.cpp
./src/utils/sha256.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5cfbd1f0..ed579993 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -386,6 +386,8 @@ SET(SRCS
utils/stringutils.cpp
utils/stringutils.h
utils/mutex.h
+ utils/mkdir.cpp
+ utils/mkdir.h
utils/xml.cpp
utils/xml.h
animatedsprite.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index e7dc3685..a9ac7dff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -286,6 +286,8 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
utils/dtor.h \
utils/gettext.h \
utils/mathutils.h \
+ utils/mkdir.cpp \
+ utils/mkdir.h \
utils/sha256.cpp \
utils/sha256.h \
utils/stringutils.cpp \
diff --git a/src/client.cpp b/src/client.cpp
index 5651f968..9ef6bc96 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -73,6 +73,7 @@
#include "resources/resourcemanager.h"
#include "utils/gettext.h"
+#include "utils/mkdir.h"
#include "utils/stringutils.h"
#ifdef __APPLE__
@@ -204,6 +205,8 @@ Client::Client(const Options &options):
assert(!mInstance);
mInstance = this;
+ logger = new Logger;
+
// Load branding information
if (!options.brandingPath.empty())
{
@@ -214,7 +217,6 @@ Client::Client(const Options &options):
initScreenshotDir(options.screenshotDir);
// Configure logger
- logger = new Logger;
logger->setLogFile(homeDir + std::string("/mana.log"));
// Log the mana version
@@ -970,14 +972,8 @@ void Client::initHomeDir(const Options &options)
"/." + branding.getValue("appShort", "mana");
#endif
}
-#if defined WIN32
- if (!CreateDirectory(homeDir.c_str(), 0) &&
- GetLastError() != ERROR_ALREADY_EXISTS)
-#else
- // Create home directory if it doesn't exist already
- if ((mkdir(homeDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) &&
- (errno != EEXIST))
-#endif
+
+ if (mkdir_r(homeDir.c_str()))
{
logger->error(strprintf(_("%s doesn't exist and can't be created! "
"Exiting."), homeDir.c_str()));
diff --git a/src/log.cpp b/src/log.cpp
index 432d1b04..ba1610fd 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -35,7 +35,7 @@
#include <sys/time.h>
Logger::Logger():
- mLogToStandardOut(false),
+ mLogToStandardOut(true),
mChatWindow(NULL)
{
}
@@ -61,11 +61,6 @@ void Logger::setLogFile(const std::string &logFilename)
void Logger::log(const char *log_text, ...)
{
- if (!mLogFile.is_open())
- {
- return;
- }
-
char* buf = new char[1024];
va_list ap;
@@ -94,7 +89,10 @@ void Logger::log(const char *log_text, ...)
<< (int)((tv.tv_usec / 10000) % 100)
<< "] ";
- mLogFile << timeStr.str() << buf << std::endl;
+ if (mLogFile.is_open())
+ {
+ mLogFile << timeStr.str() << buf << std::endl;
+ }
if (mLogToStandardOut)
{