1 /* Invisible Vector Library
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module mkziptest
/*is aliced*/;
22 import iv
.vfs
.writers
.zip
;
25 void main (string
[] args
) {
26 auto method
= ZipWriter
.Method
.Deflate
;
28 for (usize idx
= 1; idx
< args
.length
;) {
29 string arg
= args
[idx
];
31 import std
.algorithm
: remove
;
32 args
= args
.remove(idx
);
35 if (arg
.length
== 0) {
36 import std
.algorithm
: remove
;
37 args
= args
.remove(idx
);
42 case "--lzma": method
= ZipWriter
.Method
.Lzma
; break;
43 case "--store": method
= ZipWriter
.Method
.Store
; break;
44 case "--deflate": method
= ZipWriter
.Method
.Deflate
; break;
45 default: writeln("invalid argument: '", arg
, "'"); throw new Exception("boom");
47 import std
.algorithm
: remove
;
48 args
= args
.remove(idx
);
54 if (args
.length
< 2) {
55 writeln("usage: mkziptest arc.zip [files...]");
56 throw new Exception("boom");
59 auto fo
= VFile(args
[1], "w");
61 auto zw
= new ZipWriter(fo
);
62 scope(failure
) if (zw
.isOpen
) zw
.abort();
64 if (args
.length
== 2) {
65 vfsRegister
!"first"(new VFSDriverDiskListed(".", true)); // data dir, will be looked last
66 foreach (const ref de; vfsAllFiles()) {
67 if (de.name
.endsWithCI(".zip")) continue;
69 zw
.pack(VFile(de.name
), de.name
, ZipFileTime(de.modtime
), method
);
72 foreach (string fname
; args
[2..$]) {
76 zw
.pack(VFile(fname
), fname
, ZipFileTime(fname
.timeLastModified
.toUTC
.toUnixTime()), method
);