12 void main (string
[] args
) {
13 if (args
.length
!= 2) {
14 writeln("usage: mkwad dir");
18 auto fo
= VFile(args
[1].baseName
~".wad", "w");
20 if (args
[1].baseName
== "mminer") {
21 fo
.rawWriteExact("IWAD");
23 fo
.rawWriteExact("PWAD");
25 fo
.writeNum
!uint(0); // file count
26 fo
.writeNum
!uint(0); // dir offset
32 foreach (DirEntry
de; dirEntries(args
[1], SpanMode
.shallow
)) {
36 foreach (char ch
; de.name
.baseName
.stripExtension
) {
37 if (ch
>= 'a' && ch
<= 'z') ch
-= 32;
40 //if (name.indexOf('.') >= 0) continue;
41 if (!de.name
.isFile
) continue;
42 if (name
.length
> 8) continue;
45 auto fi
= VFile(de.name
);
47 ff
.name
[0..name
.length
] = name
[];
48 ff
.ofs
= cast(uint)fo
.tell
;
49 ff
.size
= cast(uint)fi
.size
;
51 auto rd
= fi
.rawRead(buf
[]);
52 if (rd
.length
== 0) break;
59 auto dofs
= cast(uint)fo
.tell
;
61 foreach (const ref fi
; files
) {
62 fo
.writeNum
!uint(fi
.ofs
);
63 fo
.writeNum
!uint(fi
.size
);
64 fo
.rawWriteExact(fi
.name
[]);
69 fo
.writeNum
!uint(cast(uint)files
.length
);
70 fo
.writeNum
!uint(dofs
);