Get the current position in a file or ByteBuffer.

@return Current position in a file
553673
private long getCurrentPosition() {
        long pos;
        if (!useLoadBuf) {
            return in.position();
        }
        try {
            if (in != null) {
                pos = (channel.position() - in.remaining());
            } else {
                pos = channel.position();
            }
            return pos;
        } catch (Exception e) {
            log.error("Error getCurrentPosition", e);
            return 0;
        }
    }
663215
private WsByteBuffer getBuffer() {
        WsByteBuffer buffer = this._output[this.outputIndex];
        if (null == buffer) {
            buffer = getNewByteBuffer();
            buffer.clear();
            this._output[this.outputIndex] = buffer;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "getBuffer, new buffer -->" + buffer + " ,outputIndex -->" + this.outputIndex);
            }
        } else if (!buffer.hasRemaining()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "getBuffer, buffer  -->" + buffer + " ,outputIndex -->" + this.outputIndex + " ,outputLength -->" + this._output.length);
            }
            buffer.flip();
            this.outputIndex++;
            // next array spot may or may not exist from previous iterations
            if (null == this._output[this.outputIndex]) {
                this._output[this.outputIndex] = getNewByteBuffer();
            }
            buffer = this._output[this.outputIndex];
            buffer.clear();
        }
        return buffer;
    }
323433
@Override
	public  float getProgress() throws IOException {
	if (start == end) {
	      return 0.0f;
	    } else {
	      return Math.min(1.0f, (getFilePosition() - start) / (float)(end - start));
	    }
	}
470841
@Override
    public ByteBuffer getBuffer()
    {
        //  If we are expected to read large message, we'll opt for zero-
        //  copy, i.e. we'll ask caller to fill the data directly to the
        //  message. Note that subsequent read(s) are non-blocking, thus
        //  each single read reads at most SO_RCVBUF bytes at once not
        //  depending on how large is the chunk returned from here.
        //  As a consequence, large messages being received won't block
        //  other engines running in the same I/O thread for excessive
        //  amounts of time.
        if (toRead >= bufsize) {
            zeroCopy = true;
            return readPos.duplicate();
        }
        else {
            zeroCopy = false;
            buf.clear();
            return buf;
        }
    }
696183
public synchronized byte[] getBuffer() {
        byte[] dest = new byte[buf.length];
        System.arraycopy(buf, 0, dest, 0, dest.length);
        return dest;
    }
347599
public long getCurrentPosition() {
        try {
            return mPlayer.getCurrentPosition();
        } catch(Exception e) {
            Log.e(TAG, e.getMessage());
            return -1;
        }
    }
739160
public function tell()
    {
        if (!$this->stream) {
            throw new RuntimeException('No stream');
        }

        $position = ftell($this->stream);
        if (!$position) {
            throw new RuntimeException('Cannot get current position');
        }

        return $position;
    }
140386
private void getNextFileToRead() throws IOException {
    if (this.currentFile != null && this.currentFileItr != null) {
      closeCurrentFile();
      incrementBytesReadCounter();
    }

    while (!this.hasNext && !this.filesToPull.isEmpty()) {
      this.currentFile = this.filesToPull.remove(0);
      this.currentFileItr = downloadFile(this.currentFile);
      this.hasNext = this.currentFileItr == null ? false : this.currentFileItr.hasNext();
      LOG.info("Will start downloading file: " + this.currentFile);
    }
  }
682328
public static byte[] getBytes(ByteBuffer buf) {
    int savedPos = buf.position();
    byte [] newBytes = new byte[buf.remaining()];
    buf.get(newBytes);
    buf.position(savedPos);
    return newBytes;
  }
249545
@Nonnull
  public ByteBuffer getByteBuffer() {
    if (base instanceof byte[] && offset >= BYTE_ARRAY_OFFSET) {
      final byte[] bytes = (byte[]) base;

      // the offset includes an object header... this is only needed for unsafe copies
      final long arrayOffset = offset - BYTE_ARRAY_OFFSET;

      // verify that the offset and length points somewhere inside the byte array
      // and that the offset can safely be truncated to a 32-bit integer
      if ((long) bytes.length < arrayOffset + numBytes) {
        throw new ArrayIndexOutOfBoundsException();
      }

      return ByteBuffer.wrap(bytes, (int) arrayOffset, numBytes);
    } else {
      return ByteBuffer.wrap(getBytes());
    }
  }
912858
@Override public float getProgress() {
		if (length == 0)
			return 1;

		if (!isBGZF)
			return (float)(in.getPosition() - fileStart) / length;

		try {
			if (in.peek() == -1)
				return 1;
		} catch (IOException e) {
			return 1;
		}

		// Add 1 to the denominator to make sure that we never report 1 here.
		return (float)((bci.getFilePointer() >>> 16) - fileStart) / (length + 1);
	}
698827
@InterfaceAudience.Private
  @InterfaceStability.Unstable
  public synchronized long remainingInFile() throws IOException {
    return objectCache.get(objName).getContentLength() - pos;
  }
892196
protected int position()
  {
    if (tc.isEntryEnabled()) Tr.entry(tc, "position", this);

    int position = _absolutePosition + _buffer.position();

    if (tc.isEntryEnabled()) Tr.exit(tc, "position", new Integer(position));
    return position;
  }
1374340
public byte[] getBuffer() {
        if(buf == null)
            return null;
        if(offset == 0 && length == buf.length)
            return buf;
        else {
            byte[] retval=new byte[length];
            System.arraycopy(buf, offset, retval, 0, length);
            return retval;
        }
    }
1043009
public long getAdjustedFileAlignment() {
		long fileAlign = get(FILE_ALIGNMENT);
		if (isLowAlignmentMode()) {
			return 1;
		}
		if (fileAlign < 512) { // TODO correct?
			fileAlign = 512;
		}
		// TODO what happens for too big alignment?
		// TODO this is just a test, verify
		if (fileAlign % 512 != 0) {
			long rest = fileAlign % 512;
			fileAlign += (512 - rest);
		}
		return fileAlign;
	}
727132
@Override
    public SourcePosition position() {
        JavaFileObject path;
        return ((path = getOverviewPath()) == null) ?
            null :
            SourcePositionImpl.make(path, Position.NOPOS, null);
    }
1193571
public long getLagBytes() {
    try {
      if (inputEditStream != null && inputEditStream.isInProgress()) {
        // for file journals it may happen that we read a segment finalized
        // by primary, but not refreshed by the standby, so length() returns 0
        // hence we take max(-1,lag)
        return Math.max(-1,
            inputEditStream.length() - this.inputEditStream.getPosition());
      }
      return -1;
    } catch (IOException ex) {
      LOG.error("Error getting the lag", ex);
      return -1;
    }
  }