Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if not args[1] then
- local disc = "/disk"
- end
- if not args[2] then
- local output = "diskBackup"
- end
- --[[
- Filesystem
- explorer
- by Creator
- ]]--
- local ignore = {}
- local filesystem = {}
- local function readFile(path)
- local file = fs.open(path,"r")
- local variable = file.readAll()
- file.close()
- return variable
- end
- local function isNotBanned(path)
- for i,v in pairs(ignore) do
- if v == path then
- return false
- end
- end
- return true
- end
- local function explore(dir)
- local buffer = {}
- local sBuffer = fs.list(dir)
- for i,v in pairs(sBuffer) do
- sleep(0.05)
- if isNotBanned(dir.."/"..v) then
- if fs.isDir(dir.."/"..v) then
- if v ~= ".git" then
- print("Compressing directory: "..dir.."/"..v)
- buffer[v] = explore(dir.."/"..v)
- end
- else
- print("Compressing file: "..dir.."/"..v)
- buffer[v] = readFile(dir.."/"..v)
- end
- end
- end
- return buffer
- end
- append = [[
- local function writeFile(path,content)
- local file = fs.open(path,"w")
- file.write(content)
- file.close()
- end
- function writeDown(input,dir)
- for i,v in pairs(input) do
- if type(v) == "table" then
- writeDown(v,dir.."/"..i)
- elseif type(v) == "string" then
- writeFile(dir.."/"..i,v)
- end
- end
- end
- args = {...}
- if #args == 0 then
- print("Please input a destination folder.")
- else
- writeDown(inputTable,args[1])
- end
- ]]
- local filesystem = explore(disc)
- local file = fs.open(output,"w")
- file.write("inputTable = "..textutils.serialize(filesystem)) --[[.."\n\n\n\n\n\n\n\n\n"..append]]
- file.close()
- if data and data["deflate"] and data["inflate"] then
- local f = fs.open(output,"r")
- local dat = f.readAll()
- f.close()
- local f = fs.open(output,"w")
- f.write(data.deflate(dat))
- f.close()
- end
- print("Output: "..output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement