From 41e695ee9730a8ab9ba5b7b93f51aa98a1234b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Fri, 21 Mar 2014 15:12:07 +0200 Subject: [PATCH] libshell|LocalServer: Asking for the error log path --- .../libshell/include/de/shell/localserver.h | 7 ++++++ doomsday/libshell/src/localserver.cpp | 25 ++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/doomsday/libshell/include/de/shell/localserver.h b/doomsday/libshell/include/de/shell/localserver.h index b7935220f5..c5c0a85b19 100644 --- a/doomsday/libshell/include/de/shell/localserver.h +++ b/doomsday/libshell/include/de/shell/localserver.h @@ -61,6 +61,13 @@ class LIBSHELL_PUBLIC LocalServer */ Link *openLink(); + /** + * Reads the path of the error log. This is useful after a failed server start. + * + * @return Native path of the error log. + */ + NativePath errorLogPath() const; + private: DENG2_PRIVATE(d) }; diff --git a/doomsday/libshell/src/localserver.cpp b/doomsday/libshell/src/localserver.cpp index e8025af7cd..fa07a377b1 100644 --- a/doomsday/libshell/src/localserver.cpp +++ b/doomsday/libshell/src/localserver.cpp @@ -26,11 +26,14 @@ namespace de { namespace shell { +static String const ERROR_LOG_NAME = "doomsday-errors.out"; + DENG2_PIMPL_NOREF(LocalServer) { Link *link; duint16 port; String name; + NativePath userDir; Instance() : link(0), port(0) {} }; @@ -44,19 +47,24 @@ void LocalServer::setName(String const &name) d->name.replace("\"", "\\\""); // for use on command line } -void LocalServer::start(duint16 port, String const &gameMode, QStringList additionalOptions, +void LocalServer::start(duint16 port, + String const &gameMode, + QStringList additionalOptions, NativePath const &runtimePath) { d->port = port; - NativePath userDir = runtimePath; + d->userDir = runtimePath; - if(userDir.isEmpty()) + if(d->userDir.isEmpty()) { // Default runtime location. - userDir = DoomsdayInfo::defaultServerRuntimeFolder(); + d->userDir = DoomsdayInfo::defaultServerRuntimeFolder(); } + // Get rid of a previous error log in this location. + QDir(d->userDir).remove(ERROR_LOG_NAME); + DENG2_ASSERT(d->link == 0); CommandLine cmd; @@ -122,9 +130,9 @@ void LocalServer::start(duint16 port, String const &gameMode, QStringList additi #endif cmd.append("-userdir"); - cmd.append(userDir); + cmd.append(d->userDir); cmd.append("-errors"); - cmd.append("doomsday-errors.out"); + cmd.append(ERROR_LOG_NAME); cmd.append("-game"); cmd.append(gameMode); cmd.append("-cmd"); @@ -154,5 +162,10 @@ Link *LocalServer::openLink() return new Link(String("localhost:%1").arg(d->port), 30); } +NativePath LocalServer::errorLogPath() const +{ + return d->userDir / ERROR_LOG_NAME; +} + } // namespace shell } // namespace de