Merge branch 'main' of https://github.com/filoxen/workspace-detector
This commit is contained in:
+15
-1
@@ -94,7 +94,21 @@ end
|
||||
-- if recursive param is true repeatedly zlib decompress the file until it fails
|
||||
-- (modelscrape files are often double/triple zlib decompressed)
|
||||
function fileproc.zlibDecompress(contents: string, recursive: boolean?): string | boolean
|
||||
error("fileproc.zlibDecompress is not implemented.")
|
||||
assert(typeof(contents) == "string", "Expected contents to be of type 'string'")
|
||||
if recursive == nil then recursive = false end
|
||||
assert(typeof(recursive) == "boolean", "Expected recursive to be of type 'boolean'")
|
||||
local success, decompressed = pcall(function() return serde.decompress("zlib", contents) end)
|
||||
if not success then
|
||||
return false
|
||||
end
|
||||
if recursive then
|
||||
local nextDecompressed = fileproc.zlibDecompress(decompressed, true)
|
||||
while nextDecompressed do
|
||||
decompressed = nextDecompressed
|
||||
nextDecompressed = fileproc.zlibDecompress(decompressed, true)
|
||||
end
|
||||
end
|
||||
return decompressed
|
||||
end
|
||||
|
||||
return fileproc
|
||||
|
||||
Reference in New Issue
Block a user