textlayouter: added method to get marked text
[iv.d.git] / vfs / samples / gextract.d
blobfaede5c87a5e8295228ebd96378633c2c9aff66b
1 #!/usr/bin/env rdmd
2 /* Invisible Vector Library
3 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
4 * Understanding is not required. Only obedience.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, version 3 of the License ONLY.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import iv.vfs.io;
20 public import iv.vfs.arc.abuse;
21 public import iv.vfs.arc.arcanum;
22 public import iv.vfs.arc.arcz;
23 public import iv.vfs.arc.bsa;
24 public import iv.vfs.arc.dfwad;
25 //public import iv.vfs.arc.dunepak; no signature
26 //public import iv.vfs.arc.f2dat; // no signature
27 //public import iv.vfs.arc.toeedat; // conflicts with arcanum
28 public import iv.vfs.arc.wad2;
31 __gshared ubyte[1024*1024] buf;
34 void extractFile (const(char)[] fname) {
35 import std.file : mkdirRecurse;
36 import std.path : dirName;
37 try {
38 auto fl = VFile(fname);
39 write(fl.size, " ");
40 string destname = "_unp/"~fname.idup;
41 mkdirRecurse(destname.dirName);
42 auto fo = VFile(destname, "w");
43 for (;;) {
44 auto rd = fl.rawRead(buf);
45 if (rd.length == 0) break;
46 fo.rawWriteExact(rd);
48 writeln("OK");
49 } catch (Exception e) {
50 writeln("ERROR!");
51 writeln(e.toString);
56 void main (string[] args) {
57 if (args.length < 2) assert(0, "PAK?");
59 string aname = args[1];
60 try {
61 vfsAddPak(aname);
62 } catch (Exception e) {
63 writeln("ERROR adding archive '", aname, "'!");
64 throw e;
67 if (args.length > 2) {
68 foreach (string fname; args[2..$]) {
69 write("extracting '", fname, "' ... ");
70 extractFile(fname);
72 } else {
73 foreach_reverse (const ref de; vfsFileList) {
74 write("extracting '", de.name, "' ... ");
75 extractFile(de.name);