@CanIgnoreReturnValue
  public boolean truncate(long size) {
    if (size >= this.size) {
      return false;
    }

    long lastPosition = size - 1;
    this.size = size;

    int newBlockCount = blockIndex(lastPosition) + 1;
    int blocksToRemove = blockCount - newBlockCount;
    if (blocksToRemove > 0) {
      disk.free(this, blocksToRemove);
    }

    return true;
  }
Truncates this file to the given {@code size}. If the given size is less than the current size
of this file, the size of the file is reduced to the given size and any bytes beyond that size
are lost. If the given size is greater than the current size of the file, this method does
nothing. Returns {@code true} if this file was modified by the call (its size changed) and
{@code false} otherwise.
jimfs/src/main/java/com/google/common/jimfs/RegularFile.java