bbBlock truncate ( Object caller , int version , int pos ) { assert mutation_in_progress ( caller , version ) ; if ( 0 > pos || pos > this . _buf_limit ) throw new IllegalArgumentException ( ) ; // clear out all the blocks in use from the last in use // to the block where the eof will be located bbBlock b = null ; for ( int idx = this . _next_block_position - 1 ; idx >= 0 ; idx -- ) { b = this . _blocks . get ( idx ) ; if ( b . _offset <= pos ) break ; b . clearBlock ( ) ; } if ( b == null ) { throw new IllegalStateException ( "block missing at position " + pos ) ; } // reset the next block position to account for this. this . _next_block_position = b . _idx + 1 ; // on the block where eof is, set it's limit appropriately b . _limit = pos - b . _offset ; // set the overall buffer limits this . _buf_limit = pos ; b = this . findBlockForRead ( pos , version , b , pos ) ; return b ; }
treat the limit as the end of file