private List < FileOffset > select ( long offset , long length ) { if ( offset + length > this . size ) { throw new IllegalArgumentException ( "Buffer overrun (" + offset + " + " + length + " > " + this . size + ") !" ) ; } List < FileOffset > selected = new LinkedList < FileOffset > ( ) ; long bytes = 0 ; for ( FileStorage file : this . files ) { if ( file . offset ( ) >= offset + length ) { break ; } if ( file . offset ( ) + file . size ( ) < offset ) { continue ; } long position = offset - file . offset ( ) ; position = position > 0 ? position : 0 ; long size = Math . min ( file . size ( ) - position , length - bytes ) ; selected . add ( new FileOffset ( file , position , size ) ) ; bytes += size ; } if ( selected . size ( ) == 0 || bytes < length ) { throw new IllegalStateException ( "Buffer underrun (only got " + bytes + " out of " + length + " byte(s) requested)!" ) ; } return selected ; }
Select the group of files impacted by an operation .