mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 09:31:59 +00:00
Ensure DEFAULT_RESOURCE_DIRECTORY is a string.
This commit is contained in:
parent
487680e8d1
commit
9f249970b0
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
|
#define _STRINGIFY(x) #x
|
||||||
|
#define ENSURE_STRING_MACRO_ARGUMENT(x) _STRINGIFY(x)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_InitializeRequest : public IpcMessage<Ipc_InitializeRequest> {
|
struct Ipc_InitializeRequest : public IpcMessage<Ipc_InitializeRequest> {
|
||||||
const static IpcId kIpcId = IpcId::Initialize;
|
const static IpcId kIpcId = IpcId::Initialize;
|
||||||
@ -86,11 +89,12 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
|||||||
|
|
||||||
// Ensure there is a resource directory.
|
// Ensure there is a resource directory.
|
||||||
if (config->resourceDirectory.empty()) {
|
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) {
|
if (defaultResourceDirectory.find("..") != std::string::npos) {
|
||||||
std::string executablePath = GetExecutablePath();
|
std::string executablePath = GetExecutablePath();
|
||||||
size_t pos = executablePath.find_last_of('/');
|
size_t pos = executablePath.find_last_of('/');
|
||||||
config->resourceDirectory = executablePath.substr(0, pos+1);
|
config->resourceDirectory = executablePath.substr(0, pos + 1);
|
||||||
config->resourceDirectory += defaultResourceDirectory;
|
config->resourceDirectory += defaultResourceDirectory;
|
||||||
} else {
|
} else {
|
||||||
config->resourceDirectory = defaultResourceDirectory;
|
config->resourceDirectory = defaultResourceDirectory;
|
||||||
|
Loading…
Reference in New Issue
Block a user