diff options
Diffstat (limited to 'tools/meta_tools.lua')
-rw-r--r-- | tools/meta_tools.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/meta_tools.lua b/tools/meta_tools.lua new file mode 100644 index 0000000..006e156 --- /dev/null +++ b/tools/meta_tools.lua @@ -0,0 +1,53 @@ +local meta_tools = {} + +function meta_tools.file_exists(name) + local f = io.open(name, 'r') + if f ~= nil then + io.close(f) + return true + else + return false + end +end + +function meta_tools.read_link_file(name) + local f = io.open(name, 'r') + if f ~= nil then + local output = {} + for line in f:lines() do + table.insert(output, line) + end + f:close() + return output + else + return {} + end +end + +function meta_tools.write_link_file(name, links) + local f = io.open(name, 'w') + for i,v in ipairs(links) do + f:write(string.format("%s\n", v)) + end + f:close() +end + +function meta_tools.get_note(note_name) + local file = io.open(string.format("build/%s.meta", note_name), "r") + local note = {} + + for line in file:lines() do + local sep = string.find(line, ",") + local index = string.sub(line, 1, sep-1) + local content = string.sub(line, sep+1, -1) + + note[index] = content + end + + note["note_name"] = note_name + + file:close() + return note +end + +return meta_tools |