private boolean blocksEquals ( Block [ ] a1 , Block [ ] a2 , boolean closedFile ) { if ( a1 == a2 ) return true ; if ( a1 == null || a2 == null || a2 . length != a1 . length ) return false ; for ( int i = 0 ; i < a1 . length ; i ++ ) { Block b1 = a1 [ i ] ; Block b2 = a2 [ i ] ; if ( b1 == b2 ) continue ; if ( b1 == null || b2 == null ) return false ; // compare ids and gen stamps if ( ! ( b1 . getBlockId ( ) == b2 . getBlockId ( ) && b1 . getGenerationStamp ( ) == b2 . getGenerationStamp ( ) ) ) return false ; // for open files check len-2 blocks only if ( ! closedFile && i >= a1 . length - 2 ) continue ; // check block size if ( b1 . getNumBytes ( ) != b2 . getNumBytes ( ) ) return false ; } return true ; }
Comapre two arrays of blocks . If the file is open do not compare sizes of the blocks .