Fallback to "/" when no CWD for a given client was found

This commit is contained in:
Maschell 2022-08-09 00:11:32 +02:00
parent 3e7b9b3fef
commit 897bc37ae4
2 changed files with 6 additions and 4 deletions

View File

@ -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;
}

View File

@ -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);