-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathzip.src
More file actions
35 lines (27 loc) · 832 Bytes
/
zip.src
File metadata and controls
35 lines (27 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
zipString = "@@@@@@@@";
zipSpacer = "::::::::";
targetFolder = params[0];
output = params[1];
c = get_shell.host_computer;
rootFolder = c.File(targetFolder);
if not rootFolder.is_folder then
exit(targetFolder + "is not a folder!");
end if;
baseFolder = rootFolder.path;
trimLength = baseFolder.len;
zipContent = "";
recurseFolder = function(folder, zipContent)
for file in folder.get_files
if not file.is_binary then
zipContent = zipContent + file.path[trimLength:] + zipString + file.content + zipSpacer;
end if;
end for;
for foldex in folder.get_folders
zipContent = recurseFolder(foldex, zipContent);
end for;
return zipContent;
end function
zipContent = recurseFolder(rootFolder, "");
c.touch(c.current_path, output);
outputFile = c.File(c.current_path + "/" + output);
outputFile.set_content(zipContent);