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

HRESULT ImageMediumBase::protectedInit ( VirtualBox *  aVirtualBox,
CBSTR  aLocation,
const Guid aId 
) [protected]

Initializes the image medium object by opening an image file at the specified location.

Parameters:
aVirtualBox Parent VirtualBox object.
aLocation Path to the image file (can be relative to the VirtualBox home directory).
aId UUID of the image.

Definition at line 939 of file MediumImpl.cpp.

References AssertReturn, CheckComRCReturnRC, com::Guid::isEmpty(), LogFlowThisFunc, MediumBase::mVirtualBox, MediumBase::queryInfo(), com::Guid::raw(), com::SupportErrorInfoBase::setError(), MediumBase::setLocation(), and unconst().

{
    LogFlowThisFunc (("aLocation='%ls', aId={%RTuuid}\n", aLocation, aId.raw()));

    AssertReturn (aVirtualBox, E_INVALIDARG);
    AssertReturn (aLocation, E_INVALIDARG);
    AssertReturn (!aId.isEmpty(), E_INVALIDARG);

    /* Enclose the state transition NotReady->InInit->Ready */
    AutoInitSpan autoInitSpan (this);
    AssertReturn (autoInitSpan.isOk(), E_FAIL);

    HRESULT rc = S_OK;

    /* share parent weakly */
    unconst (mVirtualBox) = aVirtualBox;

    /* register with parent early, since uninit() will unconditionally
     * unregister on failure */
    mVirtualBox->addDependentChild (this);

    /* there must be a storage unit */
    m.state = MediaState_Created;

    unconst (m.id) = aId;
    rc = setLocation (aLocation);
    CheckComRCReturnRC (rc);

    LogFlowThisFunc (("m.locationFull='%ls'\n", m.locationFull.raw()));

    /* get all the information about the medium from the file */
    rc = queryInfo();

    if (SUCCEEDED(rc))
    {
        /* if the image file is not accessible, it's not acceptable for the
         * newly opened media so convert this into an error */
        if (!m.lastAccessError.isEmpty())
            rc = setError (VBOX_E_FILE_ERROR, Utf8Str (m.lastAccessError));
    }

    /* Confirm a successful initialization when it's the case */
    if (SUCCEEDED (rc))
        autoInitSpan.setSucceeded();

    return rc;
}


Generated by  Doxygen 1.6.0   Back to index