TrueZIP 6.8.3

de.schlichtherle.io.rof
Class MemoryMappedReadOnlyFile

java.lang.Object
  extended by de.schlichtherle.io.rof.AbstractReadOnlyFile
      extended by de.schlichtherle.io.rof.MemoryMappedReadOnlyFile
All Implemented Interfaces:
ReadOnlyFile

Deprecated. This class does not reliably work on the Windows platform, and hence its not used in TrueZIP. The reason is that the mapped file remains allocated until the garbage collector frees it even if the file channel and/or the RandomAccessFile has been closed. Subsequent delete/write operations on the file will then fail. For more information, please refer to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154.

public class MemoryMappedReadOnlyFile
extends AbstractReadOnlyFile

A ReadOnlyFile implementation using channels to map the underlying file into memory. This class supports files larger than Integer.MAX_VALUE.

Author:
Christian Schlichtherle

Field Summary
private  FileChannel channel
          Deprecated.  
private  ByteBuffer window
          Deprecated.  
private static int WINDOW_LEN
          Deprecated. The length of the mapped window.
private  long windowOff
          Deprecated.  
 
Constructor Summary
MemoryMappedReadOnlyFile(File file)
          Deprecated.  
 
Method Summary
private  int available()
          Deprecated. Returns the number of bytes available in the floating window.
 void close()
          Deprecated.  
private  void ensureOpen()
          Deprecated. Ensures that this file is open.
 long getFilePointer()
          Deprecated.  
 long length()
          Deprecated.  
 int read()
          Deprecated.  
 int read(byte[] buf, int off, int len)
          Deprecated. Reads up to len bytes of data from this read only file into the given array.
 void seek(long fp)
          Deprecated. Sets the file pointer offset, measured from the beginning of this file, at which the next read occurs.
private  void window(long newWindowOff)
          Deprecated.  
 
Methods inherited from class de.schlichtherle.io.rof.AbstractReadOnlyFile
read, readFully, readFully, skipBytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WINDOW_LEN

private static final int WINDOW_LEN
Deprecated. 
The length of the mapped window.

See Also:
Constant Field Values

channel

private FileChannel channel
Deprecated. 

windowOff

private long windowOff
Deprecated. 

window

private ByteBuffer window
Deprecated. 
Constructor Detail

MemoryMappedReadOnlyFile

public MemoryMappedReadOnlyFile(File file)
                         throws FileNotFoundException
Deprecated. 
Throws:
FileNotFoundException
Method Detail

available

private final int available()
                     throws IOException
Deprecated. 
Returns the number of bytes available in the floating window. The window is positioned so that at least one byte is available unless the end of the file has been reached.

Returns:
The number of bytes available in the floating window. If zero, the end of the file has been reached.
Throws:
IOException

window

private void window(long newWindowOff)
             throws IOException
Deprecated. 
Throws:
IOException

length

public long length()
            throws IOException
Deprecated. 
Throws:
IOException

getFilePointer

public long getFilePointer()
                    throws IOException
Deprecated. 
Throws:
IOException

seek

public void seek(long fp)
          throws IOException
Deprecated. 
Description copied from interface: ReadOnlyFile
Sets the file pointer offset, measured from the beginning of this file, at which the next read occurs. Whether the offset may be set beyond the end of the file is up to the implementor. For example, the SimpleReadOnlyFile subclasses RandomAccessFile and passes "r" as a parameter to the superclass constructor. On the Windows platform, this implementation allows to seek past the end of file, but on the Linux platform it doesn't.

Parameters:
fp - The offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
Throws:
IOException - If pos is less than 0 or if an I/O error occurs.

read

public int read()
         throws IOException
Deprecated. 
Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Deprecated. 
Description copied from interface: ReadOnlyFile
Reads up to len bytes of data from this read only file into the given array. This method blocks until at least one byte of input is available.

Parameters:
buf - The buffer to fill with data.
off - The start offset of the data.
len - The maximum number of bytes to read.
Returns:
The total number of bytes read, or -1 if there is no more data because the end of the file has been reached.
Throws:
IOException - On any I/O related issue.

close

public void close()
           throws IOException
Deprecated. 
Throws:
IOException

ensureOpen

private final void ensureOpen()
                       throws IOException
Deprecated. 
Ensures that this file is open.

Throws:
IOException - If the preconditions do not hold.

TrueZIP 6.8.3

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.