blob: f46f43fec3680c97123359cad3621422f8d9215d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*
* TestFS.java
* Copyright (C) 2003
*
* $Id: TestFS.java,v 1.1 2004-07-07 19:59:56 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.qcommon;
import jake2.game.Cmd;
import jake2.imageio.ImageFrame;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.TreeSet;
import java.util.logging.*;
import javax.imageio.ImageIO;
import javax.imageio.stream.MemoryCacheImageInputStream;
/**
* TestFS
*
* @author cwei
*/
public class TestFS {
public static void main(String[] args) {
System.out.println("*** Start FS test ***\n");
init();
FS.InitFilesystem();
Cmd.ExecuteString("link unknown.pcx ../../baseq2/space.pcx");
Cmd.ExecuteString("link unknown1.pcx ../../baseq2/config.cfg");
FS.Path_f();
// loescht den link
Cmd.ExecuteString("link unknown1.pcx");
FS.Path_f();
Cmd.ExecuteString("dir players/male/*.[a-zA-Z_0-9]?x");
// search for pack_t
FS.searchpath_t search;
Collection filenames = new TreeSet();
for (search = FS.fs_searchpaths; search != null; search = search.next) {
// is the element a pak file?
if (search.pack != null) {
// add all the pak file names
filenames.addAll(search.pack.files.keySet());
}
}
ImageFrame frame = new ImageFrame(null);
frame.setVisible(true);
byte[] buffer = null;
BufferedImage image = null;
for (Iterator it = filenames.iterator(); it.hasNext();) {
String filename = it.next().toString();
if (!filename.endsWith(".wal") && !filename.endsWith(".pcx")) continue;
buffer = FS.LoadFile(filename);
if (buffer != null) {
try {
image =
ImageIO.read(
new MemoryCacheImageInputStream(
new ByteArrayInputStream(buffer)));
frame.showImage(image);
frame.setTitle(filename);
Thread.sleep(15);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e1) {
}
}
}
frame.dispose();
System.gc();
Runtime rt = Runtime.getRuntime();
System.out.println(
"\nJVM total memory: " + rt.totalMemory() / 1024 + " Kbytes");
System.out.println("\n*** FS test is succeeded :-) ***");
}
static void init() {
// init the global LogManager with the logging.properties file
try {
LogManager.getLogManager().readConfiguration(
TestFS.class.getResourceAsStream("/jake2/logging.properties"));
} catch (SecurityException secEx) {
secEx.printStackTrace();
} catch (IOException ioEx) {
System.err.println(
"FATAL Error: can't load /jake2/logging.properties (classpath)");
ioEx.printStackTrace();
}
}
}
|