--[[ PROGDOR SELF-EXTRACT INSTRUCTIONS 1. Use a CC emulator, such as CCEmuRedux, so you can access your filesystem ("~/.ccemuredux/sessions/computer" on linux, something else for windows) 2. Put all the files you want to archive in a single folder. 3. Get progdor (pastebin get YXx5jjMV progdor), and choose whether or not to edit the 11th line to compress or not. (Uses CCA algorithm) 4. Use progdor on that folder. It should be a file now! 5. Get out of CCEmuRedux, and navigate to the file in the .ccemuredux/sessions/computer/[ID] folder. 6. Open it up with a text editor, remove the first line (true or false), then select all and copy it as 'data' (defined below). Don't paste it INSIDE of data; replace the existing {}. 7. If it is compressed, set the doCompress (defined below) to true. Otherwise, set it to false. 8. Set the variable fullname (defined below) to the full name of your program/files. You are done! Be sure to remove this whole comment. --]] local fullname = "full_name_here" local doCompress = false local data = {} --paste archive data here local tArg = {...} local outpath = ((tArg[1] ~= "") and tArg[1]) or (shell and shell.getRunningProgram() or "") if fs.combine("",outpath) == "rom/programs/http/pastebin" then outpath = (shell and shell.dir() or "") end local progdor = fs.getName(shell.getRunningProgram()) local dir = shell.dir() -- CCA API START -- local bit = bit32 local function pack(bn1, bn2) return bit.band(bn1, 0xFF), bit.rshift(bn1, 8) + bit.lshift(bit.band(bn2, 0xF), 4), bit.rshift(bn2, 4) end local function upack(b1, b2, b3) return (b1 + bit.lshift(bit.band(b2, 0xF), 8)), (bit.lshift(b3,4) + bit.band(bit.rshift(b2, 4), 0xF)) end local function createDict(bool) local ret = {} for i = 1, 255 do if bool then ret[string.char(i)] = i else ret[i] = string.char(i) end end if not bool then ret[256] = 256 end return ret end local function cp(sInput) local dic = createDict(true) local s = "" local ch local dlen = 256 local result = {} local temp for i = 1, #sInput do if dlen == 4095 then result[#result + 1] = dic[s] result[#result + 1] = 256 dic = createDict(true) dlen = 256 s = "" end ch = sInput:sub(i, i) temp = s..ch if dic[temp] then s = temp else result[#result + 1] = dic[s] dlen = dlen +1 dic[temp] = dlen s = ch end end result[#result + 1] = dic[s] return result end local function dc(data) local dic = createDict(false) local entry local ch local currCode local result = {} result[#result + 1] = dic[data[1]] prefix = dic[data[1]] for i = 2, #data do currCode = data[i] if currCode == 256 then dic = createDict(false) prefix = "" else entry = dic[currCode] if entry then --exists in dictionary ch = entry:sub(1, 1) result[#result + 1] = entry if prefix ~= "" then dic[#dic+1] = prefix .. ch end else ch = prefix:sub(1, 1) result[#result + 1] = prefix..ch dic[#dic + 1] = prefix..ch end prefix = dic[currCode] end end return table.concat(result) end local function trim(inp) for i = 0,2 do if inp[#inp] == 0 then inp[#inp] = nil end end end local function decompress(input) local rec = {} for i = 1, #input, 3 do if i % 66 == 0 then coroutine.yield() end rec[#rec+1], rec[#rec+2] = upack(input[i], input[i+1] or 0, input[i+2] or 0) end trim(rec) return dc(rec) end local function compress(input) local rec = {} local data = cp(input) for i=1, #data, 2 do coroutine.yield() rec[#rec+1], rec[#rec+2], rec[#rec+3] = pack(data[i], data[i+1] or 0) end trim(rec) return rec end -- CCA API END -- local explode = function(div,str) if (div=='') then return false end local pos,arr = 0,{} for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,str:sub(pos,st-1)) pos = sp + 1 end table.insert(arr,str:sub(pos)) return arr end local sanitize = function(sani,tize) local _,x = string.find(sani,tize) if x then return sani:sub(x+1) else return sani end end local tablize = function(input) if type(input) == "string" then return explode("\n",input) elseif type(input) == "table" then return table.concat(input,"\n") end end local compyress = function(input) return string.char(unpack(compress(input))) end local decompyress = function(input) local out = {} for a = 1, #input do table.insert(out,string.byte(input:sub(a,a))) end return decompress(out) end if not outpath then outpath = input end local choice = function(input,verbose) if not input then input = "yn" end if verbose then write("[") for a = 1, #input do write(input:sub(a,a):upper()) if a < #input then write(",") end end write("]?") end local evt,char repeat evt,char = os.pullEvent("char") until string.find(input:lower(),char:lower()) if verbose then print(char:upper()) end local pos = string.find(input:lower(),char:lower()) return pos, char:lower() end local doPack = function(list,output,doCompress,verbose) local tx = term.getTextColor() if fs.isReadOnly(output) and (fs.combine("",output) ~= "") then return 5 end local packageSelf = true local packageReadOnly = true local ro_asked = false local ps_asked = false if fs.exists(output) and (not fs.isDir(output)) then fs.delete(output) end local amnt = 0 for k,v in pairs(list) do amnt = amnt + 1 end local num = 0 for k,v in pairs(list) do num = num + 1 if v == true then fs.makeDir(fs.combine(output,k)) else local file = fs.open(fs.combine(output,k),"w") if verbose then write("[") if term.isColor() then term.setTextColor(colors.lightGray) end write(k) term.setTextColor(tx) write("]") end if doCompress then file.write(decompyress(tablize(v))) else file.write(tablize(v)) end file.close() local tx = term.getTextColor() if fs.getName(k):lower() == "peasant" then if term.isColor() then term.setTextColor(colors.orange) end print(" UNBURNINATED") else if term.isColor() then term.setTextColor(colors.green) end print(" GOOD") end term.setTextColor(tx) end end return 2 end if not fs.isDir(outpath) then fs.delete(outpath) end local success, res = pcall( function() return doPack(data,outpath,doCompress,true) end ) if not success then term.setTextColor(colors.white) print("\n***Something went wrong!***") return printError(res) end if res then local msgs = { [2] = "Successfully unpacked '"..fullname.."' to '"..outpath.."/'", [5] = "You don't have permission.", } print(msgs[res]) end