Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- sys_packager
- by BigSHinyToys
- ]]--
- local level = 0
- local sSlash = "/"
- local sSaveLoc = "Inst"
- local item = 0
- local function err(input)
- print("error "..tostring(input))
- error()
- end
- local partA = "["
- local partB = "="
- local partC = "]"
- local top = partA..partB..partB..partA
- local bottom = partC..partB..partB..partC
- local function addFile(sDATA,path,name)
- file = fs.open(sSaveLoc,"a")
- if file then
- file.write("local file"..item.." = "..top)
- file.write(sDATA)
- file.write(bottom.."\n")
- file.write("local file"..item.."path = \""..path..name.."\"\n")
- file.write("local file = fs.open(file"..item.."path,\"w\")\n")
- file.write("file.write(file"..item..")\n")
- file.write("file.close()\n")
- file:close()
- return true
- else
- err("add fiel faled")
- end
- end
- local function addDir(path)
- file = fs.open(sSaveLoc,"a")
- if file then
- file.write("fs.makeDir(\""..path.."\")\n")
- file:close()
- return true
- else
- err("add dir failed")
- end
- end
- local function add(path)
- level = level + 1
- for k,v in pairs(fs.list(path)) do
- if fs.isDir(path..sSlash..v) then
- if level == 1 then
- if v ~= "rom" then
- addDir(path..sSlash..v)
- add(path..sSlash..v)
- end
- else
- addDir(path..sSlash..v)
- add(path..sSlash..v)
- end
- else
- item = item + 1
- local file = fs.open(path..sSlash..v,"r")
- local sData = file.readAll()
- file.close()
- addFile(sData,path..sSlash,v)
- end
- end
- level = level - 1
- end
- if fs.exists(sSaveLoc) and not fs.isDir(sSaveLoc) then
- print("removing old "..sSaveLoc)
- fs.delete(sSaveLoc)
- end
- add("/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement