int l = (int) Math.min(len, BLOCK_SIZE - (pos & BLOCK_SIZE_MASK)); int page = (int) (pos >>> BLOCK_SIZE_SHIFT); expand(data, page); byte[] block = data[page]; int blockOffset = (int) (pos & BLOCK_SIZE_MASK);
/** * Truncate the file. * * @param newLength the new length */ void truncate(long newLength) { changeLength(newLength); long end = MathUtils.roundUpLong(newLength, BLOCK_SIZE); if (end != newLength) { int lastPage = (int) (newLength >>> BLOCK_SIZE_SHIFT); expand(data, lastPage); byte[] d = data[lastPage]; for (int i = (int) (newLength & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) { d[i] = 0; } if (compress) { compressLater(data, lastPage); } } }