Lua
Lua
Zip -- Exclude Files Based on Wildcard Matching
See more Zip Examples
Demonstrates how to use the SetExclusions method to exclude matching files from being added to a .zip.Chilkat Lua Downloads
local chilkat = require("chilkat")
local zip = chilkat.Zip.new()
local success = zip:new_zip("qa_output/x.zip")
-- Let's add files from the directory tree rooted at C:\AAWorkarea\ChilkatSampleProjects
-- However.. we want to exclude all files ending in ".cache" or ".pdb" regardless of the sub-directory.
-- Also exclude all files under any "obj" directory,
-- and we also want to exclude any .exe found under a "win10-x64" directory.
local saExcludes = chilkat.StringArray.new()
saExcludes:append("*.cache")
saExcludes:append("*.pdb")
saExcludes:append("*/obj/*")
saExcludes:append("*/win10-x64/*.exe")
zip:set_exclusions(saExcludes)
-- Append promises of paths and files to be zipped.
local recurse = true
success = zip:append_files("c:/AAWorkArea/ChilkatSampleProjects/*", recurse)
if not success then
print(zip.last_error_text)
return
end
-- Create the zip from the file and directory promises added previously.
success = zip:write_zip_and_close()
if not success then
print(zip.last_error_text)
return
end
print("Success.")