If file is under construction, set block size of the last block. It updates
file length in the same time.
344617
public synchronized  void setLastBlockSize(long blockId, long blockSize) {
    assert blocks.size() > 0;
    LocatedBlock last = blocks.get(blocks.size() - 1);
    if (underConstruction && blockSize > last.getBlockSize()) {
      assert blockId == last.getBlock().getBlockId();
      this.setFileLength(this.getFileLength() + blockSize - last.getBlockSize());
      last.setBlockSize(blockSize);

      if (LOG.isDebugEnabled()) {
        LOG.debug("DFSClient setting last block " + last + " to length "
            + blockSize + " filesize is now " + getFileLength());
      }
    }
  }
196395
private void expandIfNecessary(int minBlockCount) {
    if (minBlockCount > blocks.length) {
      this.blocks = Arrays.copyOf(blocks, nextPowerOf2(minBlockCount));
    }
  }
271796
private void updateCurrentChunk(boolean lastChunk) throws IOException {
    // Early return for the most common case.
    if (mCurrentChunk != null && mCurrentChunk.writableBytes() > 0 && !lastChunk) {
      return;
    }

    if (mCurrentChunk == null) {
      if (!lastChunk) {
        mCurrentChunk = allocateBuffer();
      }
      return;
    }

    if (mCurrentChunk.writableBytes() == 0 || lastChunk) {
      try {
        if (mCurrentChunk.readableBytes() > 0) {
          for (DataWriter dataWriter : mDataWriters) {
            mCurrentChunk.retain();
            dataWriter.writeChunk(mCurrentChunk.duplicate());
          }
        } else {
          Preconditions.checkState(lastChunk);
        }
      } finally {
        // If the packet has bytes to read, we increment its refcount explicitly for every packet
        // writer. So we need to release here. If the packet has no bytes to read, then it has
        // to be the last packet. It needs to be released as well.
        mCurrentChunk.release();
        mCurrentChunk = null;
      }
    }
    if (!lastChunk) {
      mCurrentChunk = allocateBuffer();
    }
  }
460366
def filesize(fileobj):
    
    current = fileobj.tell()
    fileobj.seek(0, 2)
    end = fileobj.tell()
    fileobj.seek(current)
    return end
579823
def increment(self, size: int):
        '''
        '''
        assert size >= 0, size

        self.files += 1
        self.size += size
        self.bandwidth_meter.feed(size)
378913
public void setFileSize() {
        if (arr[DatenFilm.FILM_GROESSE].isEmpty())
            arr[DatenFilm.FILM_GROESSE] = FileSize.laengeString(arr[DatenFilm.FILM_URL]);
    }
943357
def set_data_length(self, length):
        # type: (int) -> None
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('Directory Record not yet initialized')
        self.data_length = length
526724
def set_data_length(self, length):
        # type: (int) -> None
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('Directory Record not yet initialized')

        len_diff = length - self.info_len
        if len_diff > 0:
            # If we are increasing the length, update the last alloc_desc up
            # to the max of 0x3ffff800, and throw an exception if we overflow.
            new_len = self.alloc_descs[-1][0] + len_diff
            if new_len > 0x3ffff800:
                raise pycdlibexception.PyCdlibInvalidInput('Cannot increase the size of a UDF file beyond the current descriptor')
            self.alloc_descs[-1][0] = new_len
        elif len_diff < 0:
            # We are decreasing the length.  It's possible we are removing one
            # or more alloc_descs, so run through the list updating all of the
            # descriptors and remove any we no longer need.
            len_left = length
            alloc_descs_needed = 0
            index = 0
            while len_left > 0:
                this_len = min(len_left, 0x3ffff800)
                alloc_descs_needed += 1
                self.alloc_descs[index][0] = this_len
                index += 1
                len_left -= this_len

            self.alloc_descs = self.alloc_descs[:alloc_descs_needed]

        self.info_len = length
1056813
private void ensureCapacity() {
    if (size < resourceIds.length) {
      return;
    }
    int newCapacity = (resourceIds.length * 3) / 2 + 1;
    // Increase size of resourceIds
    String[] oldResourceIds = resourceIds;
    resourceIds = new String[newCapacity];
    System.arraycopy(oldResourceIds, 0, resourceIds, 0, oldResourceIds.length);
    // Increase size of blockData
    int[] oldBlockData = blockData;
    blockData = new int[newCapacity * blockInts];
    System.arraycopy(oldBlockData, 0, blockData, 0, oldBlockData.length);
    // Increase size of byResourceIndices (no need to copy old, because would be restored in method ensureSorted)
    resourceIdsIndex = new int[newCapacity];
    sorted = false;
  }
1033574
private boolean checkBlockSize(Block block, INodeFile inode) {
    if (block.getNumBytes() < 0) {
      return false;
    }
    BlockInfo[] blocks = inode.getBlocks();
    if (blocks.length == 0) {
      return false;
    }
    return block.getNumBytes() <= inode.getPreferredBlockSize();
  }
1085348
private void prepareForWrite(long pos, long len) throws IOException {
    long end = pos + len;

    // allocate any additional blocks needed
    int lastBlockIndex = blockCount - 1;
    int endBlockIndex = blockIndex(end - 1);

    if (endBlockIndex > lastBlockIndex) {
      int additionalBlocksNeeded = endBlockIndex - lastBlockIndex;
      disk.allocate(this, additionalBlocksNeeded);
    }

    // zero bytes between current size and pos
    if (pos > size) {
      long remaining = pos - size;

      int blockIndex = blockIndex(size);
      byte[] block = blocks[blockIndex];
      int off = offsetInBlock(size);

      remaining -= zero(block, off, length(off, remaining));

      while (remaining > 0) {
        block = blocks[++blockIndex];

        remaining -= zero(block, 0, length(remaining));
      }

      size = pos;
    }
  }
429828
private void validateBlockSize(byte[] descriptor) throws IOException {
        int blockSize = Util.getUInt16Both(descriptor, 129);
        if (blockSize != Constants.DEFAULT_BLOCK_SIZE) {
            throw new LoopFileSystemException("Invalid block size: " + blockSize);
        }
    }
1249169
def _init_append(self):
        
        if self._content_length:
            # Adjust size if content length specified
            with _handle_azure_exception():
                self._resize(
                    content_length=self._content_length, **self._client_kwargs)
                self._reset_head()

        # Make initial seek position to current end of file
        self._seek = self._size
1062146
protected void setLogFileSize(long newFileSize)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "setLogFileSize"
                        , "newFileSize=" + newFileSize + "(long)"
                            );

        // Note where we are in the log file.
        long initialFilePosition = filePosition;

        synchronized (newFileSizeRequestLock) {
            // Force the new file size to be a whole number of pages.
            this.newFileSize = (newFileSize / pageSize) * pageSize;
            newFileSizeRequested = true;
            newFileSizeException = null;
            logFileSizeRequested = newFileSize;
            // We have not yet seen the log file wrap.
            boolean wrapped = false;

            // Keep requesting checkpoints until the start and end of the log data are both 
            // before the new end of the log, without the user log data wrapping round the 
            // end of the logFile.
            while (newFileSizeRequested) {

                // Check there is still some chance of fitting the current log into the new one.
                // and that we have not wrapped round the log file without succeeding.
                long fileSpaceAvailable = getLogFileSpaceLeft();
                long newFileSpaceAvailable = fileSpaceAvailable - fileLogHeader.fileSize + newFileSize;
                float newOcupancy = (float) 1.0 - (float) (newFileSpaceAvailable) / (float) (newFileSize);
                if (newOcupancy > objectManagerState.logFullPostCheckpointThreshold
                    || wrapped) {
                    newFileSizeRequested = false;
                    logFileSizeRequested = 0;
                    if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                        trace.exit(this,
                                   cclass,
                                   "setLogFileSize",
                                   new Object[] { new Long(fileLogHeader.fileSize),
                                                 new Long(newFileSize),
                                                 new Float(newOcupancy) });
                    throw new LogFileSizeTooSmallException(this
                                                           , fileLogHeader.fileSize
                                                           , newFileSize
                                                           , fileSpaceAvailable
                                                           , newOcupancy
                                                           , objectManagerState.logFullPostCheckpointThreshold);
                } // if (   (fileSpaceLeft...

                if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
                    trace.debug(this,
                                cclass,
                                "setLogFileSize",
                                new Object[] { new Long(filePosition),
                                              new Long(initialFilePosition) });

                // If we have wrapped round the log file, give up after the next attempt to satisfy the 
                // request. 
                if (filePosition < initialFilePosition)
                    wrapped = true;

                // We have released the lock on writingFlushSet set so now we can request a checkpoint and
                // see if we are successful.
                objectManagerState.waitForCheckpoint(true);

                // Speed up moving the filePosition by writing a reasonable ammount of data.
                // The folowing is dangerous because it can cause the request to fail if we 
                // are trying to reduce the log file size close to the minimum possible. 
//        PaddingLogRecord paddingLogRecord = new PaddingLogRecord(logBufferSize/2);
//        writeNext(paddingLogRecord
//                 ,0
//                 ,true
//                 );

            } // while (newFileSizeRequested...

            logFileSizeRequested = 0;
        } // synchronized (newFileSizeRequestLock).                                            

        if (newFileSizeException != null) {
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass
                           , "setLogFileSize"
                           , "via PermanentIOException newFileSizeException=" + newFileSizeException + "(PermanentIOException)"
                                );
            throw newFileSizeException;
        }

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "setLogFileSize"
                            );
    }
1316222
private boolean fillLast() throws IOException {
        int count;

        if (lastFilled == pageSize) {
            throw new IllegalStateException();
        }
        count = src.read(pages[lastNo], lastFilled, pageSize - lastFilled);
        if (count <= 0) {
            if (count == 0) {
                throw new IllegalStateException();
            }
            return false;
        }
        lastFilled += count;
        return true;
    }
540986
def completedLength
      num = @completeBlocks.countSet
      # Last block may be smaller
      extra = 0
      if @completeBlocks.set?(@completeBlocks.length-1)
        num -= 1
        extra = @lastBlockLength
      end
      num*@blockSize + extra
    end
631970
@Override
    public void updateProgress(final long readBytes, final long contentLength) {
        if (readBytes > maxSize || contentLength > maxSize) {
            LOG.error("User tried to upload more than was allowed ({}).", maxSize);
            interruptUploadDueToFileSizeExceeded(maxSize);
            return;
        }
        if (isUploadInterrupted()) {
            // Upload interruption is delayed maybe another event is fired
            // before
            return;
        }

        publishUploadProgressEvent(fileUploadId, readBytes, contentLength);
    }