summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2017-07-14 08:29:46 -0500
committer cracyc <cracyc@users.noreply.github.com>2017-07-14 08:29:46 -0500
commit3a751b164eb3740bc2dfb37fe260d921e9fa1b3d (patch)
tree1b22b5e27fc5827556ec1cc48fde9c07bab318c0
parent8a1c44f44acd021481a5b33632da358c631a5f3b (diff)
plugins/cheat: create dirs (nw)
-rw-r--r--plugins/cheat/init.lua21
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()