Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- BINNARY READ / WRITE
- ]]--
- local function readAsString(fileParth)
- if fs.exists(fileParth) then
- if not fs.isDir(fileParth) then
- local output = ""
- local file = fs.open(fileParth,"rb")
- local dec = file:read()
- while dec do
- sChar = string.char(dec)
- output = output..sChar
- dec = file:read()
- end
- return output
- else
- error("ERROR folder not file")
- end
- else
- error("ERROR File not found")
- end
- end
- local function writeString2Binary(fileParth,sDATA)
- file = fs.open(fileParth,"wb")
- if file then
- for i = 1,#sDATA do
- file:write(string.byte(string.sub(sDATA,i,i)))
- end
- file:close()
- return true
- end
- end
- local sFile = readAsString("rom/user/BENCH4.lua")
- print(sFile)
- writeString2Binary("test",sFile)
Advertisement
Add Comment
Please, Sign In to add comment