docs: private SmooshedWriter delegateSmooshedWriter(final String name, final long size) throws IOException
    {
      final File tmpFile = new File(baseDir, name);
      filesInProcess.add(tmpFile);
  
      return new SmooshedWriter()
      {
        private final GatheringByteChannel channel =
            FileChannel.open(
                tmpFile.toPath(),
                StandardOpenOption.WRITE,
                StandardOpenOption.CREATE,
                StandardOpenOption.TRUNCATE_EXISTING
            );
  
        private int currOffset = 0;
  
        @Override
        public void close() throws IOException
        {
          channel.close();
          completedFiles.add(tmpFile);
          filesInProcess.remove(tmpFile);
  
          if (!writerCurrentlyInUse) {
            mergeWithSmoosher();
          }
        }
  
        public int bytesLeft()
        {
          return (int) (size - currOffset);
        }
  
        @Override
        public int write(ByteBuffer buffer) throws IOException
        {
          return addToOffset(channel.write(buffer));
        }
  
        @Override
        public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
        {
          return addToOffset(channel.write(srcs, offset, length));
        }
  
        @Override
        public long write(ByteBuffer[] srcs) throws IOException
        {
          return addToOffset(channel.write(srcs));
        }
  
        public int addToOffset(long numBytesWritten)
        {
          if (numBytesWritten > bytesLeft()) {
            throw new ISE("Wrote more bytes[%,d] than available[%,d]. Don't do that.", numBytesWritten, bytesLeft());
          }
          currOffset += numBytesWritten;
  
          return Ints.checkedCast(numBytesWritten);
        }
  
        @Override
        public boolean isOpen()
        {
          return channel.isOpen();
        }
  
      };
  
    }