Debian Codegraph @

icmake/logzip

raw
1 // names may be a series of files in src, not a wildcard.
2 // if it's empty then all files in src are used.
3 // the files are gzipped and logged in dest.
4 // src and dest do not have to end in /
5
6 void logZip(string src, string names, string dest)
7 {
8 list files;
9 int idx;
10 string file;
11
12 chdir(g_cwd);
13
14 md(dest);
15 dest += "/";
16
17 if (src != "")
18 {
19 if (listlen(makelist(O_DIR, src)) == 0)
20 {
21 printf("Warning: ", src, " not found: can't install ", src, names,
22 " at ", dest, "\n");
23 return;
24 }
25 chdir(src);
26 }
27
28 if (names == "")
29 files = makelist("*");
30 else
31 files = strtok(names, " ");
32
33 for (idx = listlen(files); idx--; )
34 {
35 file = files[idx];
36 run("gzip -n -9 < " + file + " > " + file + ".gz");
37 }
38
39 run("tar cf - *.gz | (cd " + g_cwd + "; cd " + dest + "; tar xf -)");
40
41 run("rm *.gz");
42 }
43
44
45