diff options
author | Carsten Weisse <[email protected]> | 2004-11-10 20:41:40 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2004-11-10 20:41:40 +0000 |
commit | 191c118ae561d1eed21557167616f4f9d6c42c2c (patch) | |
tree | c0210bd811540846ad86c1f40c4d9fe6d2092709 /src/jake2/qcommon | |
parent | 2bbeb9408b3703d2e4a711c2fff7b0cdbeb547e6 (diff) |
pak file is mmapped and buffers will be sliced
Diffstat (limited to 'src/jake2/qcommon')
-rw-r--r-- | src/jake2/qcommon/FS.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java index 0e6aa90..5bab93e 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.11 2004-10-28 21:09:11 cawe Exp $ + * $Id: FS.java,v 1.12 2004-11-10 20:41:40 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -71,6 +71,8 @@ public final class FS extends Globals { String filename; RandomAccessFile handle; + + ByteBuffer backbuffer; int numfiles; @@ -449,11 +451,16 @@ public final class FS extends Globals { pak.handle = new RandomAccessFile(pak.filename, "r"); } // open a new file on the pakfile - - channel = pak.handle.getChannel(); - buffer = channel.map(FileChannel.MapMode.READ_ONLY, - entry.filepos, entry.filelen); - channel.close(); + if (pak.backbuffer == null) { + channel = pak.handle.getChannel(); + pak.backbuffer = channel.map( + FileChannel.MapMode.READ_ONLY, 0, + pak.handle.length()); + channel.close(); + } + pak.backbuffer.position(entry.filepos); + buffer = pak.backbuffer.slice(); + buffer.limit(entry.filelen); return buffer; } } else { |