LBPHacker

NBS Downloader

Feb 17th, 2013
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. -- A little help for WeaponMaster
  2.  
  3. if not http then
  4.         print("HTTP API is disabled")
  5.         return false
  6. end
  7. local destination = "songs"
  8. local url = ({...})[1]
  9. local httpHandle = http.get(url)
  10. if not httpHandle then
  11.         print("Error downloading file")
  12.         return false
  13. end
  14. if not fs.exists(destination) then fs.makeDir(destination) end
  15. if not fs.isDir(destination) then
  16.         print("Destination must be a directory")
  17.         return false
  18. end
  19. local fileHandle = fs.open(destination .. "/" .. fs.getName(url), "w")
  20. if not fileHandle then
  21.         print("Error opening file")
  22.         return false
  23. end
  24. fileHandle.write(httpHandle.readAll())
  25. httpHandle.close()
  26. fileHandle.close()
  27. print("Done")
Add Comment
Please, Sign In to add comment