import java.io.File;
import java.io.IOException;
-import java.nio.MappedByteBuffer;
+import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.util.UUID;
return index;
}
- /**
- * Gets the filechannel of the streamInput. This is a limited Java resource.
- *
- * @return the filechannel
- */
- public FileChannel getFileChannel() {
- return fileChannel;
- }
-
/**
* Gets the filename of the streamInput file.
*
+ ((packetIndex.getPacketSizeBits() + 7) / 8);
}
+ ByteBuffer getByteBufferAt(long position, long size) throws IOException {
+ return fileChannel.map(MapMode.READ_ONLY, position, size);
+ }
+
/**
* @param fileSizeBytes
* @param packetOffsetBytes
* @return
* @throws CTFReaderException
*/
- private MappedByteBuffer createPacketBitBuffer(long fileSizeBytes,
+ private ByteBuffer createPacketBitBuffer(long fileSizeBytes,
long packetOffsetBytes, StreamInputPacketIndexEntry packetIndex,
BitBuffer bitBuffer) throws CTFReaderException {
/*
/*
* Map the packet.
*/
- MappedByteBuffer bb;
+ ByteBuffer bb;
try {
- bb = fileChannel.map(MapMode.READ_ONLY, packetOffsetBytes, mapSize);
+ bb = getByteBufferAt(packetOffsetBytes, mapSize);
} catch (IOException e) {
throw new CTFReaderException(e);
}
package org.eclipse.linuxtools.ctf.core.trace;
import java.io.IOException;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel.MapMode;
+import java.nio.ByteBuffer;
import java.util.Collection;
import org.eclipse.linuxtools.ctf.core.CTFStrings;
/*
* Change the map of the BitBuffer.
*/
- MappedByteBuffer bb = null;
+ ByteBuffer bb = null;
try {
- bb = streamInputReader.getStreamInput().getFileChannel()
- .map(MapMode.READ_ONLY,
+ bb = streamInputReader.getStreamInput().getByteBufferAt(
this.currentPacket.getOffsetBytes(),
(this.currentPacket.getPacketSizeBits() + 7) / 8);
} catch (IOException e) {