diff options
author | 2017-07-14 08:29:46 -0500 | |
---|---|---|
committer | 2017-07-14 08:29:46 -0500 | |
commit | 3a751b164eb3740bc2dfb37fe260d921e9fa1b3d (patch) | |
tree | 1b22b5e27fc5827556ec1cc48fde9c07bab318c0 /plugins/cheat | |
parent | 8a1c44f44acd021481a5b33632da358c631a5f3b (diff) |
plugins/cheat: create dirs (nw)
Diffstat (limited to 'plugins/cheat')
-rw-r--r-- | plugins/cheat/init.lua | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua index e0f284437aa..56da68dbc56 100644 --- a/plugins/cheat/init.lua +++ b/plugins/cheat/init.lua @@ -113,7 +113,7 @@ function cheat.startplugin() local function load_hotkeys() local json = require("json") - local file = io.open(manager:machine():options().entries.cheatpath:value():match("([^;]+)") .. "/" .. cheatname .. "_hotkeys.json", "r") + local file = io.open(lfs.env_replace(manager:machine():options().entries.cheatpath:value():match("([^;]+)")) .. "/" .. cheatname .. "_hotkeys.json", "r") if not file then return end @@ -139,7 +139,24 @@ function cheat.startplugin() end if #hotkeys > 0 then local json = require("json") - local file = io.open(manager:machine():options().entries.cheatpath:value():match("([^;]+)") .. "/" .. cheatname .. "_hotkeys.json", "w+") + local path = lfs.env_replace(manager:machine():options().entries.cheatpath:value():match("([^;]+)")) + local attr = lfs.attributes(path) + if not attr then + lfs.mkdir(path) + elseif attr.mode ~= "directory" then -- uhhh? + return + end + if cheatname:find("/", 1, true) then + local softpath = path .. "/" .. cheatname:match("([^/]+)") + local attr = lfs.attributes(softpath) + if not attr then + lfs.mkdir(softpath) + elseif attr.mode ~= "directory" then -- uhhh? + return + end + end + + local file = io.open(path .. "/" .. cheatname .. "_hotkeys.json", "w+") if file then file:write(json.stringify(hotkeys, {indent = true})) file:close() |