Advertisement
Alakazard12

Database

Nov 10th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. -- Variables --
  2. local tArgs = {...}
  3. local databaseURL = "https://dl.dropbox.com/u/6320944/apt-get/database"
  4. local databaseSoruce = {}
  5.  
  6. -- Functions --
  7. local function fileSystemSetup()
  8.         if not fs.exists("/.apt-get/") then
  9.                 fs.makeDir("/.apt-get/")
  10.                 fs.makeDir("/.apt-get/database")
  11.         end
  12. end
  13.  
  14. local function getHttp(url, save)
  15.         local request = http.get(url)
  16.         if type(request) == "table" then
  17.                 f = fs.open(save, "w")
  18.                 f.write(request.readAll())
  19.                 f.close()
  20.                 return true
  21.         else
  22.                 return false
  23.         end
  24. end
  25.  
  26. local function getPastebin(code, save)
  27.         getHttp("http://pastebin.com/raw.php?i=" ..code)
  28. end
  29.  
  30. local function databaseUpdate()
  31.         f = fs.open("/.apt-get/source")
  32.         databaseSoruce = textutils.unserialize(f.readAll())
  33.         f.close()
  34.  
  35.         for k, v in pairs(databaseSoruce) do
  36.                 getHttp(v, "/.apt-get/database/" ..k)
  37.         end
  38. end
  39. -- Main --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement