If you want I can give you a slightly modified version of my script I used to publish Lua Script System as one file on Pastebin.
Here it is:
local tArgs = {}
local savetable = {}
function compact(path)
local file
for k, v in ipairs(fs.list(path)) do
if fs.isDir(path.."/"..v) then
compact(path.."/"..v)
elseif fs.exists(path.."/"..v) then
file = fs.open(path.."/"..v, "r")
if file then
savetable[path.."/"..v] = file.readAll()
file.close()
end
end
end
end
if tArgs > 1 then
print("Serializing...")
compact(tArgs[1])
print("Saving to File...")
local file = fs.open(tArgs[2], "w")
file.write(textutils.serialize(savetable))
file.close()
else
print("Usage: merge <folder merge="" to=""> <file path="">")
end
</file></folder>
Here is the code to uncompress a file.
local function createFolderForFile(path)
local curpath = path
local startHere = 1
while true do
local nextSlash = string.find(string.sub(path, startHere, -1), "/")
if not nextSlash then return end
nextSlash = nextSlash + startHere
local folderToCreate = string.sub(curpath, 0, nextSlash - 1)
if not fs.isDir(folderToCreate) then
local ok, err = pcall(fs.makeDir, folderToCreate)
if not ok then
if string.find(err, "Out of space") then
error("Out of space.")
end
end
end
startHere = nextSlash
end
end
function uncompact(location)
local handle = fs.open(location, "r")
folderStructureS = handle.readAll()
handle.close()
local folderStructure = textutils.unserialize(folderStructureS)
for k, v in pairs(folderStructure) do
createFolderForFile(k)
local file = fs.open(k, "w")
if file then
file.write(v)
local ok, err = pcall(file.close)
if not ok then
if string.find(err, "Out of space") then
outOfSpaceError()
end
end
end
sleep()
end
end
if tArgs > 0 then
print("Unserializing...")
uncompact(Args[1])
else
print("Usage: unmerge <file path to uncompact>")
end