deadbeef.Tools
Class FileBuffer

java.lang.Object
  extended by deadbeef.Tools.FileBuffer

public class FileBuffer
extends java.lang.Object

Very simple version of a read only memory mapped file used for parsing large packet based files.

Author:
0xdeadbeef

Constructor Summary
FileBuffer(java.lang.String fname)
          Constructor.
 
Method Summary
 void close()
          Close file buffer (closes input file).
 void finalize()
           
 int getByte(long ofs)
          Read one byte from the buffer.
 void getBytes(long ofs, byte[] b, int len)
          Read multiple bytes from the buffer.
 int getDWord(long ofs)
          Read one (big endian) 32bit dword from the buffer.
 int getDWordLE(long ofs)
          Read one (little endian) 32bit dword from the buffer.
 long getSize()
          Get size of input file.
 int getWord(long ofs)
          Read one (big endian) 16bit word from the buffer.
 int getWordLE(long ofs)
          Read one (little endian) 16bit word from the buffer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileBuffer

public FileBuffer(java.lang.String fname)
           throws FileBufferException
Constructor.

Parameters:
fname - File name of input file
Throws:
FileBufferException
Method Detail

getByte

public int getByte(long ofs)
            throws FileBufferException
Read one byte from the buffer.

Parameters:
ofs - File offset
Returns:
Byte read from the buffer
Throws:
FileBufferException

getWord

public int getWord(long ofs)
            throws FileBufferException
Read one (big endian) 16bit word from the buffer.

Parameters:
ofs - File offset
Returns:
Word read from the buffer
Throws:
FileBufferException

getWordLE

public int getWordLE(long ofs)
              throws FileBufferException
Read one (little endian) 16bit word from the buffer.

Parameters:
ofs - File offset
Returns:
Word read from the buffer
Throws:
FileBufferException

getDWord

public int getDWord(long ofs)
             throws FileBufferException
Read one (big endian) 32bit dword from the buffer.

Parameters:
ofs - File offset
Returns:
Dword read from the buffer
Throws:
FileBufferException

getDWordLE

public int getDWordLE(long ofs)
               throws FileBufferException
Read one (little endian) 32bit dword from the buffer.

Parameters:
ofs - File offset
Returns:
Dword read from the buffer
Throws:
FileBufferException

getBytes

public void getBytes(long ofs,
                     byte[] b,
                     int len)
              throws FileBufferException
Read multiple bytes from the buffer.

Parameters:
ofs - File offset
b - Buffer to store bytes (has to be allocated and large enough)
len - Number of bytes to read
Throws:
FileBufferException

getSize

public long getSize()
Get size of input file.

Returns:
Size of input file in bytes

close

public void close()
Close file buffer (closes input file).


finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable