Advertisement
programcreator

Compress MOD

Mar 9th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. --[[
  2.     Filesystem
  3.     explorer
  4.     by Creator
  5. ]]--
  6.  
  7.  
  8. local filesystem = {}
  9.  
  10. local function readFile(path)
  11.     if not fs.exists(path) then
  12.         return false, "No such file!"
  13.     end
  14.     local file = fs.open(path,"r")
  15.     local variable = file.readAll()
  16.     file.close()
  17.     return variable
  18. end
  19.  
  20.  
  21.  
  22. local append = [[
  23. local function writeFile(path,content)
  24.     local file = fs.open(path,"w")
  25.     file.write(content)
  26.     file.close()
  27. end
  28. function writeDown(input, dir)
  29.     for i,v in pairs(input) do
  30.         writeFile(dir.."/"..i, v)
  31.     end
  32. end
  33.  
  34. args = {...}
  35. if #args == 0 then
  36.     print("Please input a destination folder.")
  37. else
  38.     writeDown(inputTable,args[1])
  39. end
  40. print("Finished installation...")
  41. ]]
  42.  
  43. compress = function(basePath, paths, output)
  44.     local files = {}
  45.     assert(type(paths) == "table", "A table, bro!")
  46.     for i,v in pairs(paths) do
  47.         local data = readFile(basePath.."/"..v)
  48.         if data then
  49.             files[v] = data
  50.         end
  51.     end
  52.     local file = fs.open(output,"w")
  53.     file.write("inputTable = "..textutils.serialize(files).."\n\n\n\n\n\n\n\n\n"..append)
  54.     file.close()
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement