Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get( code, file )
- if not http then
- return false, "no_http"
- end
- resp = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode( code ))
- if resp then
- handler = io.open(file,"w")
- handler:write(resp.readAll())
- handler:close()
- return true, "success"
- else
- return false, "fail"
- end
- end
- function getRaw( url, file )
- if not http then
- return false, "no_http"
- end
- resp = http.get(textutils.urlEncode( url ))
- if resp then
- handler = io.open(file,"w")
- handler:write(resp.readAll())
- handler:close()
- return true, "success"
- else
- return false, "fail"
- end
- end
- function append( file, text, w )
- -- w = true if you don't want to add an end of line character
- local handler = fs.open( file, "a" )
- if not w then
- handler.writeLine( text )
- handler.close()
- return true, "append_line"
- else
- handler.write( text )
- handler.close()
- return true,"append"
- end
- end
- function read( file, all )
- -- all = true if you want to load all of the file's content.
- local handler = fs.open( file, "r")
- if not all then
- local line = handler.readLine()
- handler.close()
- else
- local line = handler.readAll()
- handler.close()
- end
- return true, line
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement