diff options
author | Carsten Weisse <[email protected]> | 2005-05-20 15:05:54 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-05-20 15:05:54 +0000 |
commit | 152b65e3999ba7a618cdf934c830351f2f76cff2 (patch) | |
tree | 28142b1812c414d84a76f8aa60dfdaa307e4022d /src/jake2 | |
parent | c003a7569723338b7339f34b37fba17028e0144d (diff) |
replace the javax.imageio with nio file operations
Diffstat (limited to 'src/jake2')
-rw-r--r-- | src/jake2/qcommon/FS.java | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java index 5bab93e..b4fe7eb 100644 --- a/src/jake2/qcommon/FS.java +++ b/src/jake2/qcommon/FS.java @@ -2,7 +2,7 @@ * FS.java * Copyright (C) 2003 * - * $Id: FS.java,v 1.12 2004-11-10 20:41:40 cawe Exp $ + * $Id: FS.java,v 1.13 2005-05-20 15:05:54 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -36,8 +36,6 @@ import java.nio.ByteOrder; import java.nio.channels.FileChannel; import java.util.*; -import javax.imageio.stream.FileImageInputStream; - /** * FS * @@ -527,24 +525,26 @@ public final class FS extends Globals { dpackheader_t header; Hashtable newfiles; + RandomAccessFile file; int numpackfiles = 0; pack_t pack = null; - RandomAccessFile file; - FileImageInputStream packhandle; // unsigned checksum; // try { - packhandle = new FileImageInputStream(file = new RandomAccessFile( - packfile, "r")); - packhandle.setByteOrder(ByteOrder.LITTLE_ENDIAN); - - if (packhandle.length() < 1) + file = new RandomAccessFile(packfile, "r"); + FileChannel fc = file.getChannel(); + ByteBuffer packhandle = fc.map(FileChannel.MapMode.READ_ONLY, 0, file.length()); + packhandle.order(ByteOrder.LITTLE_ENDIAN); + + fc.close(); + + if (packhandle == null || packhandle.limit() < 1) return null; // header = new dpackheader_t(); - header.ident = packhandle.readInt(); - header.dirofs = packhandle.readInt(); - header.dirlen = packhandle.readInt(); + header.ident = packhandle.getInt(); + header.dirofs = packhandle.getInt(); + header.dirlen = packhandle.getInt(); if (header.ident != IDPAKHEADER) Com.Error(Globals.ERR_FATAL, packfile + " is not a packfile"); @@ -557,18 +557,18 @@ public final class FS extends Globals { newfiles = new Hashtable(numpackfiles); - packhandle.seek(header.dirofs); + packhandle.position(header.dirofs); // parse the directory packfile_t entry = null; for (int i = 0; i < numpackfiles; i++) { - packhandle.readFully(tmpText); + packhandle.get(tmpText); entry = new packfile_t(); entry.name = new String(tmpText).trim(); - entry.filepos = packhandle.readInt(); - entry.filelen = packhandle.readInt(); + entry.filepos = packhandle.getInt(); + entry.filelen = packhandle.getInt(); newfiles.put(entry.name.toLowerCase(), entry); } |