Advertisement
Derek1017

Install

May 25th, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local function get(repoFile,saveTo)
  2. local download = http.get("https://github.com/derekseitz/Husky/tree/master") --This will make 'download' hold the contents of the file.
  3. if download then --checks if download returned true or false
  4.    local handle = download.readAll() --Reads everything in download
  5.    download.close() --remember to close the download!
  6.    local file = fs.open(saveTo,"w") --opens the file defined in 'saveTo' with the permissions to write.
  7.    file.write(handle) --writes all the stuff in handle to the file defined in 'saveTo'
  8.    file.close() --remember to close the file!
  9.   else --if returned false
  10.    print("Unable to download the file "..repoFile)
  11.    print("Make sure you have the HTTP API enabled or")
  12.    print("an internet connection!")
  13.   end --end the if
  14. end --close the function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement