Last active
April 14, 2018 05:18
-
-
Save ExtReMLapin/27b68cacaa5a67ab782f to your computer and use it in GitHub Desktop.
testfinddecompressall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filelist = {} | |
local folderblacklist = {"garrysmod/downloads/", "garrysmod/cache/", "garrysmod/maps/","platform/", "garrysmod/gamemodes/", "garrysmod/models/", "garrysmod/settings/", "garrysmod/materials/","garrysmod/resource/","garrysmod/screenshots/", "garrysmod/sound/", "sourceengine/", "garrysmod/addons/", "garrysmod/download/"} | |
local fileblacklist = {"png", "vtf", "dll", "exe", "jpg", "vmt", "vtx", "wav", "txt", "mdmp", "mdl", "res"} | |
function getallfiles(path) | |
if table.HasValue(folderblacklist, path) then return end | |
path = path or "" | |
local flist = file.Find(path .."*", "BASE_PATH") | |
local dlist = select(2,file.Find(path .."*", "BASE_PATH")) | |
if #dlist > 0 then | |
for k, v in pairs(dlist) do | |
getallfiles(path .. v .. "/") | |
end | |
end | |
for k, v in pairs(flist) do | |
local found = false; | |
for k2, v2 in pairs(fileblacklist) do | |
if string.EndsWith(v, v2) then | |
found = true; | |
break | |
end | |
end | |
if not found then | |
table.insert(filelist, path .. v ) | |
end | |
end | |
end | |
function decompress_file(inputf, outputf, doprint) | |
local i = 0; | |
while i < 10 do | |
local str = file.Read(inputf, "BASE_PATH") | |
str = string.Right(str, string.len(str)-i) | |
str = util.Decompress(str) | |
if str then | |
print("Offset of junk bytes : " .. i .. " for file : " .. inputf) | |
if doprint then print(str) end | |
if outputf then file.Write(outputf, str) end | |
return true | |
end | |
i = i +1 | |
end | |
return false | |
end | |
local time = SysTime() | |
getallfiles() | |
PrintTable(filelist) | |
print(SysTime()-time) | |
for k, v in pairs(filelist) do | |
decompress_file(v, false, false) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment