Improve setting the CWD for client, at basic error handling

This commit is contained in:
Maschell 2022-08-09 00:12:35 +02:00
parent 031ad15133
commit 78ccbd0369
1 changed files with 10 additions and 1 deletions

View File

@ -36,9 +36,18 @@ std::string getFullPathForFSClient(FSClient *pClient, const char *path) {
}
void setWorkingDirForFSClient(FSClient *client, const char *path) {
if (!path) {
DEBUG_FUNCTION_LINE_WARN("Path was NULL");
return;
}
std::lock_guard<std::mutex> workingDirLock(workingDirMutexFS);
workingDirsFS[client] = path;
std::string cwd(path);
if (cwd.empty() || cwd.back() != '/') {
cwd.push_back('/');
}
workingDirsFS[client] = cwd;
OSMemoryBarrier();
}