Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --LUA fileFuncs
- function writeDataToFile(file, data)
- --Open/Create file------------
- local wFd = io.open(file,"w")
- --Modify ---------------------
- local writeSucess = false --Determin sucess of
- if wFd:write(data) then --Write to file
- writeSucess = true
- end
- --Close ----------------------
- wFd:close()
- return writeSucess
- end
- -- see if the file exists
- function file_exists(file)
- local f = io.open(file, "rb")
- if f then f:close() end
- return f ~= nil
- end
- -- get all lines from a file, returns an empty
- -- list/table if the file does not exist
- function lines_from(file)
- if not file_exists(file) then
- return {}
- else
- lines = {}
- for line in io.lines(file) do
- lines[#lines + 1] = line
- end
- return lines
- end
- end
- function lines_from_dropbox(file)
- local dropboxPath = os.getenv("HOME").."/Documents/Dropbox.spritepack/"
- return lines_from(dropboxPath..file)
- end
- function txt_from_dropbox(file)
- local dropboxPath = os.getenv("HOME").."/Documents/Dropbox.spritepack/"
- return join(lines_from(dropboxPath..file), "\n")
- end
- function join(array, sep)
- string = ""
- for i,v in pairs(array) do
- string = string..v..sep
- end
- return string
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement