Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Filesystem
- explorer
- by Creator
- ]]--
- local args = {...}
- local ignore = {}
- if args[3] then
- local file = fs.open(args[3],"r")
- local data = file.readAll()
- file.close()
- for token in string.gmatch(data,"[^\n]+") do
- ignore[#ignore+1] = token
- end
- end
- 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)
- print("Added \""..dir.."\" as a search directory and searching now...")
- for i,v in pairs(input) do
- if type(v) == "table" then
- print("Adding \""..dir.."/"..i.."\" as a search directory...")
- writeDown(v,dir.."/"..i)
- elseif type(v) == "string" then
- print("Installing file \""..dir.."/"..i.."\"...")
- writeFile(dir.."/"..i,v)
- print("Installed file \""..dir.."/"..i.."\".")
- end
- end
- end
- function getInput(txt)
- term.setTextColor(colors.green)
- write(txt)
- term.setTextColor(colors.lime)
- write("> ")
- term.setTextColor(colors.yellow)
- local input = io.read()
- term.setTextColor(colors.white)
- return input
- end
- print("Please input a destination folder:")
- local dir = getInput(shell.getRunningProgram())
- print()
- writeDown(inputTable,dir)
- ]]
- local filesystem = explore(args[1])
- local file = fs.open(args[2],"w")
- file.write("inputTable = "..textutils.serialize(filesystem).."\n\n\n\n\n\n\n\n\n"..append)
- file.close()
Add Comment
Please, Sign In to add comment