Skip to content

Commit

Permalink
Fix issue on Linux when .local/share doesn't exist;
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornbytes committed Jun 14, 2024
1 parent f78af61 commit 2054ddc
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/modules/filesystem/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,31 @@ bool lovrFilesystemSetIdentity(const char* identity, bool precedence) {
return false;
}

// Append /LOVR, mkdir
// Append /LOVR
state.savePath[cursor++] = SLASH;
memcpy(state.savePath + cursor, "LOVR", strlen("LOVR"));
cursor += strlen("LOVR");
state.savePath[cursor] = '\0';
fs_mkdir(state.savePath);

// Append /<identity>, mkdir
// Append /<identity>
state.savePath[cursor++] = SLASH;
memcpy(state.savePath + cursor, identity, length);
cursor += length;
state.savePath[cursor] = '\0';
state.savePathLength = cursor;
fs_mkdir(state.savePath);

// mkdir -p
FileInfo info;
if (!fs_stat(state.savePath, &info)) {
for (char* slash = strchr(state.savePath, SLASH); slash; slash = strchr(slash + 1, SLASH)) {
*slash = '\0';
fs_mkdir(state.savePath);
*slash = SLASH;
}

if (!fs_mkdir(state.savePath)) {
return false;
}
}

// Set the identity string
memcpy(state.identity, identity, length + 1);
Expand Down

0 comments on commit 2054ddc

Please sign in to comment.