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 list
/*is aliced*/;
23 void die(A
...) (string fmt
, A args
) {
24 import std
.stdio
: stderr
;
25 static if (args
.length
== 0) {
26 stderr
.writeln("FATAL: ", fmt
);
28 import std
.string
: format
;
29 auto s
= format(fmt
, args
);
30 stderr
.writeln("FATAL: ", s
);
32 import core
.exception
: ExitException
;
33 throw new ExitException();
37 void main (string
[] args
) {
38 import std
.stdio
: writeln
;
39 if (args
.length
!= 2) die("one argument expected");
40 auto btf
= BTField
.load(args
[1]);
41 if (!btf
.isDict
) die("benc file is not a dictionary");
42 auto info
= "info" in btf
;
43 if (info
is null) die("no \"info\" entry");
44 if (!info
.isDict
) die("invalid \"info\" entry");
45 auto name
= "name" in *info
;
46 if (name
is null) die("no \"name\" entry");
47 if (!name
.isStr
) die("invalid \"name\" entry");
48 if (auto files
= "files" in *info
) {
49 if (!files
.isList
) die("invalid \"files\" entry");
50 foreach (ref fi
; files
.vlist
) {
51 string fpath
= name
.vstr
;
52 if (!fi
.isDict
) die("invalid file entry");
53 if (auto pt
= "path" in fi
) {
54 if (!pt
.isList
) die("invalid \"path\" entry");
55 foreach (ref dd; pt
.vlist
) {
56 if (!dd.isStr
) die("invalid \"path\" entry");
61 die("invalid file entry");