Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

static int krdrBufFillBuffer ( PKRDRBUF  pThis,
KFOFF  off 
) [static]

Fills the buffer with file bits starting at the specified offset.

0 on success, pfnRead error code on failure.
pThis The instance.
off Where to start reading.

Definition at line 229 of file kRdrBuffered.cpp.

References KRDRBUF::cbBuf, KRDRBUF::cbBufValid, KRDRBUF::cbFile, KRDRBUF::fTainedByLineQ, K_FALSE, KSIZE, KRDRBUF::offBuf, KRDRBUF::offBufEnd, KRDRBUF::pbBuf, KRDROPS::pfnRead, KRDR::pOps, and KRDRBUF::pRdr.

Referenced by krdrBufRead().

    kRdrAssert(off < pThis->cbFile);

    /* Reposition the buffer if it's past the end of the file so that
       we maximize its usability. We leave one unused byte at the end
       of the buffer so kRdrBufLineQ can terminate its string properly.
       Of course, this might end up re-reading a lot of stuff for no
       future gain, but whatever... */
    kRdrAssert(pThis->cbBuf <= pThis->cbFile + 1);
    KFOFF cbLeft = pThis->cbFile - off;
    KSIZE cbRead = pThis->cbBuf;
    if ((KSSIZE)cbRead - 1 >= cbLeft)
        off = pThis->cbFile - cbRead;
    int rc = pThis->pRdr->pOps->pfnRead(pThis->pRdr, pThis->pbBuf, cbRead, off);
    if (!rc)
        pThis->offBuf = off;
        pThis->offBufEnd = off + cbRead;
        pThis->cbBufValid = cbRead;
        pThis->offBuf = pThis->offBufEnd = 0;
        pThis->cbBufValid = 0;
    pThis->fTainedByLineQ = K_FALSE;
    return rc;

Generated by  Doxygen 1.6.0   Back to index