Merge pull request #269 from jmiskovic/savemount

Config parameter for save directory precedence
This commit is contained in:
Bjorn 2020-07-29 16:26:07 -06:00 committed by GitHub
commit 617d508d68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -291,7 +291,8 @@ static int l_lovrFilesystemRemove(lua_State* L) {
static int l_lovrFilesystemSetIdentity(lua_State* L) {
const char* identity = luaL_checkstring(L, 1);
lovrFilesystemSetIdentity(identity);
bool precedence = lua_toboolean(L, 2);
lovrFilesystemSetIdentity(identity, precedence);
return 0;
}

View File

@ -277,7 +277,7 @@ const char* lovrFilesystemGetIdentity() {
return state.identity[0] == '\0' ? NULL : state.identity;
}
bool lovrFilesystemSetIdentity(const char* identity) {
bool lovrFilesystemSetIdentity(const char* identity, bool precedence) {
size_t length = strlen(identity);
// Identity can only be set once, and can't be empty
@ -332,7 +332,7 @@ bool lovrFilesystemSetIdentity(const char* identity) {
#endif
// Mount the fully resolved save path
if (!lovrFilesystemMount(state.savePath, NULL, false, NULL)) {
if (!lovrFilesystemMount(state.savePath, NULL, !precedence, NULL)) {
return false;
}

View File

@ -26,7 +26,7 @@ uint64_t lovrFilesystemGetLastModified(const char* path);
void* lovrFilesystemRead(const char* path, size_t bytes, size_t* bytesRead);
void lovrFilesystemGetDirectoryItems(const char* path, void (*callback)(void* context, const char* path), void* context);
const char* lovrFilesystemGetIdentity(void);
bool lovrFilesystemSetIdentity(const char* identity);
bool lovrFilesystemSetIdentity(const char* identity, bool precedence);
const char* lovrFilesystemGetSaveDirectory(void);
bool lovrFilesystemCreateDirectory(const char* path);
bool lovrFilesystemRemove(const char* path);

View File

@ -83,6 +83,7 @@ function lovr.boot()
local conf = {
version = '0.13.0',
identity = 'default',
saveprecedence = true,
hotkeys = true,
modules = {
audio = true,
@ -127,7 +128,7 @@ function lovr.boot()
if confOk and lovr.conf then confOk, confError = pcall(lovr.conf, conf) end
lovr._setConf(conf)
lovr.filesystem.setIdentity(conf.identity)
lovr.filesystem.setIdentity(conf.identity, conf.saveprecedence)
for module in pairs(conf.modules) do
if conf.modules[module] then