Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function request(url)
- local success, response = pcall(component.internet.request, url)
- if success then
- local responseData = ""
- while true do
- local data, responseChunk = response.read()
- if data then
- responseData = responseData .. data
- else
- if responseChunk then
- return false, responseChunk
- else
- return responseData
- end
- end
- end
- else
- return false, reason
- end
- end
- --БЕЗОПАСНАЯ ЗАГРУЗОЧКА
- local function getFromGitHubSafely(url, path)
- local success, reason = request(url)
- if success then
- fs.makeDirectory(fs.path(path) or "")
- fs.remove(path)
- local file = io.open(path, "w")
- file:write(success)
- file:close()
- return success
- else
- io.stderr:write("Can't download \"" .. url .. "\"!\n")
- return -1
- end
- end
- local GitHubUserUrl = "https://raw.githubusercontent.com/"
- --------------------------------- Стадия стартовой загрузки всего необходимого ---------------------------------
- local preLoadApi = {
- { paste = "RadioNurshat/OMine/master/devka.pic", path = "MineOS/Desktop/"devka.pic },
- }
- print("Downloading file list")
- applications = seri.unserialize(getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/Applications.txt", "MineOS/System/OS/Applications.txt"))
- print(" ")
- for i = 1, #preLoadApi do
- print("Downloading \"" .. fs.name(preLoadApi[i].path) .. "\"")
- getFromGitHubSafely(GitHubUserUrl .. preLoadApi[i].paste, preLoadApi[i].path)
- end
Add Comment
Please, Sign In to add comment