Ensure DEFAULT_RESOURCE_DIRECTORY is a string.

This commit is contained in:
Jacob Dufault 2017-12-15 21:06:27 -08:00
parent 487680e8d1
commit 9f249970b0

View File

@ -5,6 +5,9 @@
#include <loguru.hpp>
#define _STRINGIFY(x) #x
#define ENSURE_STRING_MACRO_ARGUMENT(x) _STRINGIFY(x)
namespace {
struct Ipc_InitializeRequest : public IpcMessage<Ipc_InitializeRequest> {
const static IpcId kIpcId = IpcId::Initialize;
@ -86,11 +89,12 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
// Ensure there is a resource directory.
if (config->resourceDirectory.empty()) {
std::string defaultResourceDirectory = std::string(DEFAULT_RESOURCE_DIRECTORY);
std::string defaultResourceDirectory = std::string(
ENSURE_STRING_MACRO_ARGUMENT(DEFAULT_RESOURCE_DIRECTORY));
if (defaultResourceDirectory.find("..") != std::string::npos) {
std::string executablePath = GetExecutablePath();
size_t pos = executablePath.find_last_of('/');
config->resourceDirectory = executablePath.substr(0, pos+1);
config->resourceDirectory = executablePath.substr(0, pos + 1);
config->resourceDirectory += defaultResourceDirectory;
} else {
config->resourceDirectory = defaultResourceDirectory;