-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.lua
41 lines (40 loc) · 984 Bytes
/
settings.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import "cjson"
function 文件是否存在(path)
import "java.io.*"
file,err=io.open(path)
if err==nil then
return true
else
return false
end
end
function settings_decode(settings)
if 文件是否存在("/sdcard") == true then
path = "/sdcard/devToolbox/config.cfg"
value = 文件是否存在(path,value)
if value == false then
write(path,"{}")
end
file = io.open(path,"r")
settings = cjson.decode(file:read("*a"))
file:close()
return settings
else
msg"请在手机设置中授予储存权限"
end
end
function settings_encode(settings)
if 文件是否存在("/sdcard") == true then
path = "/sdcard/devToolbox/config.cfg"
value = 文件是否存在(path,value)
if value == false then
write(path,"{}")
end
settings_json = cjson.encode(settings)
file = io.open(path,"w")
file:write(settings_json)
file:close()
else
msg"请在手机设置中授予储存权限"
end
end