ccryptolib/install.lua

18 lines
598 B
Lua

fs.makeDir("/ccryptolib") -- Make folder structure
function downloadDir(dir)
local data = textutils.unserialiseJSON(http.get("https://git.chrischro.me/api/v1/repos/ChrisChrome/ccryptolib/contents/" .. dir).readAll())
for _,entry in ipairs(data) do
if entry.type == "file" then -- We're gonna download it
print("Downloading " .. entry.name)
local file = http.get(entry.download_url).readAll()
local newFile = fs.open("/" .. entry.path, "w")
newFile.write(file)
newFile.close()
elseif entry.type == "dir" then
downloadDir(entry.path)
end
end
end
downloadDir("ccryptolib")