57 lines
1.5 KiB
Plaintext
Executable File
57 lines
1.5 KiB
Plaintext
Executable File
-- package a folder recursively into a rage packfile
|
|
-- KS 22/08/2006
|
|
|
|
function packageFolderRecursive(path, relativepath, except, extignore)
|
|
if path == except then
|
|
return 1
|
|
end
|
|
|
|
packageFolder(path, relativepath, extignore);
|
|
|
|
local paths = find_dirs(path);
|
|
|
|
for key, value in paths do
|
|
local subpath = path .. value .. "\\";
|
|
local relativesubpath = relativepath .. value .. "\\";
|
|
|
|
if packageFolderRecursive(subpath, relativesubpath, except, extignore) == 0 then
|
|
return 0;
|
|
end
|
|
end
|
|
return 1;
|
|
end
|
|
|
|
function packageFolder(path, relativepath, extignore)
|
|
local files = find_files( path .. "*.*" );
|
|
|
|
for key, value in files do
|
|
local ext = get_extension_from_path(value)
|
|
-- if extension ignore is nil or the file extension doesn't equal extension ignore
|
|
-- add the file to the pack
|
|
if extignore == nil or ext~=extignore then
|
|
local filename = path .. value;
|
|
local destination = relativepath .. value;
|
|
add_to_pack(filename, destination)
|
|
end
|
|
end
|
|
end
|
|
|
|
function package(packfile, path, except, compress, extignore)
|
|
if compress then
|
|
start_pack();
|
|
else
|
|
start_uncompressed_pack();
|
|
end
|
|
packageFolderRecursive(path, "\\", except, extignore);
|
|
save_pack(packfile);
|
|
close_pack();
|
|
end
|
|
|
|
local pack = get_param("pack");
|
|
local rootpath = get_param("rootpath");
|
|
local except = get_param("except");
|
|
local extignore = get_param("extignore");
|
|
local compress = get_param("compress");
|
|
package(pack, rootpath, except, compress, extignore);
|
|
|