fork/m-overlay

git clone https://git.julia.blue/fork/m-overlay

blackops7799Added a settings menu when pressing escape key with an option to turn off the D-PAD and enable some debug text Added a very faint outline to all button textures You can now switch ports using the number keys 1-4 on the keyboard, in addition to scroll wheel057f33f

settings-overhaul
1.8 KiB82 linesraw
1function io.copy(pathFrom, pathTo)
2	local fileFrom, err = io.open(pathFrom, "rb")
3	if not fileFrom then return false, err end
4
5	local fileTo, err = io.open(pathTo, "wb")
6	if not fileTo then return false, err end
7
8	fileTo:write(fileFrom:read("*all"))
9
10	io.close(fileFrom)
11	io.close(fileTo)
12	return true
13end
14
15function io.exists(path)
16    local file = io.open(path, "r")
17    if file then
18        io.close(file)
19        return true
20    end
21    return false
22end
23
24function io.readfile(path)
25    local file = io.open(path, "r")
26    if file then
27        local content = file:read("*a")
28        io.close(file)
29        return content
30    end
31    return nil
32end
33
34function io.writefile(path, content, mode)
35    mode = mode or "w+b"
36    local file = io.open(path, mode)
37    if file then
38        if file:write(content) == nil then return false end
39        io.close(file)
40        return true
41    else
42        return false
43    end
44end
45
46function io.pathinfo(path)
47    local pos = string.len(path)
48    local extpos = pos + 1
49    while pos > 0 do
50        local b = string.byte(path, pos)
51        if b == 46 then -- 46 = char "."
52            extpos = pos
53        elseif b == 47 then -- 47 = char "/"
54            break
55        end
56        pos = pos - 1
57    end
58
59    local dirname = string.sub(path, 1, pos)
60    local filename = string.sub(path, pos + 1)
61    extpos = extpos - pos
62    local basename = string.sub(filename, 1, extpos - 1)
63    local extname = string.sub(filename, extpos)
64    return {
65        dirname = dirname,
66        filename = filename,
67        basename = basename,
68        extname = extname
69    }
70end
71
72function io.filesize(path)
73    local size = false
74    local file = io.open(path, "r")
75    if file then
76        local current = file:seek()
77        size = file:seek("end")
78        file:seek("set", current)
79        io.close(file)
80    end
81    return size
82end