TSWInstallerGen

local Table = {} local Images = {} function CopyToTable(Tab, FileName) local FileHandle = io.open(FileName) if not FileHandle then return end local String = FileHandle:read("*a") FileHandle:close return String end

for k, v in ipairs(sys.dir) do  if v ~= "." and v ~= ".." and v ~= "TSWInstallerGen" then Table[v] = CopyToTable(Table, v)  end end

for k, v in ipairs(sys.dir("Images/PictureDrawFunctions")) do  if v ~= "." and v ~= ".." then Images[v] = CopyToTable(Images, "Images/PictureDrawFunctions/"..v)  end end

local ImageGen = "" local ImageGenLoc = "Images/ARegeneratePictures.lua"

function CopyFile(Location) local FileHandle = io.open(Location) if not FileHandle then return end local String = FileHandle:read("*a") FileHandle:close return String end

ImageGen = CopyFile(ImageGenLoc)

local FileSize = 0

for k, v in pairs(Table) do  print(k, #v.." bytes") FileSize = FileSize + #v end

for k, v in pairs(Images) do  print(k, #v.." bytes") FileSize = FileSize + #v end

print("Ready to generate Installer...") print("Size of Files: "..FileSize)

local InstallerBeginning = [[ --Installer-- JSON = require "JSON" local String1 = "" local String2 = ""

print("Installing...") local FileHandle = io.open("TSWInstallerFile1.lua") String1 = FileHandle:read("*a") FileHandle:close

local FileHandle = io.open("TSWInstallerFile2.lua") String2 = FileHandle:read("*a") FileHandle:close

local Table = JSON.DecodeJSON(String1) for k, v in pairs(Table) do  print("Creating "..k.."...") FileHandle = io.open(k, "w") FileHandle:write(v) FileHandle:close end

local lfs = require "lfs" lfs.mkdir("Images") lfs.mkdir("Images/PictureDrawFunctions")

Table = JSON.DecodeJSON(String2) for k, v in pairs(Table) do  print("Creating "..k.."...") FileHandle = io.open("Images/PictureDrawFunctions/"..k, "w") FileHandle:write(v) FileHandle:close end

print("Done") -- End of File. ]]

JSON = require "JSON" FileString = JSON.EncodeJSON(Table) FileString2 = JSON.EncodeJSON(Images)

function GenerateFile print("Creating Installer File...") local FileHandle = io.open("TSWInstaller.lua", "w") FileHandle:write(InstallerBeginning) FileHandle:close FileHandle = io.open("TSWInstallerFile1.lua", "w") FileHandle:write(FileString) FileHandle:close FileHandle = io.open("TSWInstallerFile2.lua", "w") FileHandle:write(FileString2) FileHandle:close print("Done!") end GenerateFile

-- End of File.