From 897bc37ae403d2774087d0b5dc60067a49826276 Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 9 Aug 2022 00:11:32 +0200 Subject: [PATCH] Fallback to "/" when no CWD for a given client was found --- src/FileUtils.cpp | 8 ++++---- src/utils/logger.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/FileUtils.cpp b/src/FileUtils.cpp index 336a7c4..102e5f5 100644 --- a/src/FileUtils.cpp +++ b/src/FileUtils.cpp @@ -21,11 +21,11 @@ std::string getFullPathForFSClient(FSClient *pClient, const char *path) { std::string res; if (path[0] != '/' && path[0] != '\\') { - if (workingDirsFS.count(pClient) > 0) { - res = string_format("%s%s", workingDirsFS.at(pClient).c_str(), path); - } else { - DEBUG_FUNCTION_LINE_ERR("Failed to find working dir for client"); + if (workingDirsFS.count(pClient) == 0) { + DEBUG_FUNCTION_LINE_WARN("No working dir found for FS client %08X, fallback to \"/\"", pClient); + workingDirsFS[pClient] = "/"; } + res = string_format("%s%s", workingDirsFS.at(pClient).c_str(), path); } else { res = path; } diff --git a/src/utils/logger.h b/src/utils/logger.h index d8498b1..a2d3423 100644 --- a/src/utils/logger.h +++ b/src/utils/logger.h @@ -38,6 +38,7 @@ extern "C" { #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) LOG(WHBLogWritef, FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS) +#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##WARN ## ", "", FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS); @@ -52,6 +53,7 @@ extern "C" { #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0) #define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##ERROR## ", "\n", FMT, ##ARGS) +#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##WARN ## ", "\n", FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, "##ERROR## ", "\n", FMT, ##ARGS);