Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MainVersionURL = "http://pastebin.com/raw.php?i=Lw73Vfin"
- local TestingVersionURL = ""
- local MainDownloadURL = "http://pastebin.com/raw.php?i=NuLBhBL3"
- local TestingDownloadURL = ""
- local function outOfSpaceError()
- error("Not enough free space available.", 0)
- end
- local function createFolderForFile(path)
- local curpath = path
- local startHere = 1
- while true do
- local nextSlash = string.find(string.sub(path, startHere, -1), "/")
- if not nextSlash then return end
- nextSlash = nextSlash + startHere
- local folderToCreate = string.sub(curpath, 0, nextSlash - 1)
- if not fs.isDir(folderToCreate) then
- local ok, err = pcall(fs.makeDir, folderToCreate)
- if not ok then
- if string.find(err, "Out of space") then
- outOfSpaceError()
- end
- end
- end
- startHere = nextSlash
- end
- end
- local function installWhistler()
- print("Downloading Whistler.data...")
- local handle = http.get(MainDownloadURL)
- print("Loading folder structure...")
- folderStructureS = handle.readAll()
- handle.close()
- local folderStructure = textutils.unserialize(folderStructureS)
- for key, value in pairs(folderStructure) do
- createFolderForFile(key)
- print("Opening "..key.."...")
- local file = fs.open(key, "w")
- if file then
- file.write(value)
- local ok, err = pcall(file.close)
- if not ok then
- if string.find(err, "Out of space") then
- outOfSpaceError()
- end
- end
- end
- sleep()
- end
- print("Updating startup file...")
- local handle = fs.open("startup", "a") or fs.open("startup", "w")
- if handle then
- handle.write('shell.run("Whistler/startup")')
- handle.close()
- end
- print("Starting...")
- shell.run("Whistler/startup")
- end
- installWhistler()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement