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

static int krdrFileAllMap ( PKRDR  pRdr,
const void **  ppvBits 
) [static]

Definition at line 959 of file kRdrFile.cpp.

References KRDRFILE::cMappings, KRDRFILE::Core, KERR_NO_MEMORY, KSIZE, NULL, KRDROPS::pfnRead, KRDROPS::pfnSize, KRDR::pOps, and KRDRFILE::pvMapping.

{
    PKRDRFILE pRdrFile = (PKRDRFILE)pRdr;

    /*
     * Do we need to map it?
     */
    if (!pRdrFile->pvMapping)
    {
        int rc;
        KFOFF cbFile = pRdrFile->Core.pOps->pfnSize(pRdr);
        KSIZE cb = (KSIZE)cbFile;
        if (cb != cbFile)
            return KERR_NO_MEMORY;

        pRdrFile->pvMapping = kHlpAlloc(cb);
        if (!pRdrFile->pvMapping)
            return KERR_NO_MEMORY;
        rc = pRdrFile->Core.pOps->pfnRead(pRdr, pRdrFile->pvMapping, cb, 0);
        if (rc)
        {
            kHlpFree(pRdrFile->pvMapping);
            pRdrFile->pvMapping = NULL;
            return rc;
        }
        pRdrFile->cMappings = 0;
    }

    *ppvBits = pRdrFile->pvMapping;
    pRdrFile->cMappings++;
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index