VirtualBox

Changeset 23235 in vbox for trunk


Ignore:
Timestamp:
Sep 22, 2009 6:15:56 PM (15 years ago)
Author:
vboxsync
Message:

API: fix opening new dvd/floppy images, introduce fallback format

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MediumImpl.cpp

    r23223 r23235  
    968968                     CBSTR aLocation,
    969969                     HDDOpenMode enOpenMode,
     970                     DeviceType_T aDeviceType,
    970971                     BOOL aSetImageId,
    971972                     const Guid &aImageId,
     
    998999    m->hddOpenMode = enOpenMode;
    9991000
    1000     rc = setLocation(aLocation);
     1001    if (aDeviceType == DeviceType_HardDisk)
     1002        rc = setLocation(aLocation);
     1003    else
     1004        rc = setLocation(aLocation, "RAW");
    10011005    CheckComRCReturnRC(rc);
    10021006
     
    33343338 * be NotCreated and will return a faiulre otherwise.
    33353339 *
    3336  * @param aLocation Location of the storage unit. If the locaiton is a FS-path,
     3340 * @param aLocation Location of the storage unit. If the location is a FS-path,
    33373341 *                  then it can be relative to the VirtualBox home directory.
     3342 * @param aFormat   Optional fallback format if it is an import and the format
     3343 *                  cannot be determined.
    33383344 *
    33393345 * @note Must be called from under this object's write lock.
    33403346 */
    3341 HRESULT Medium::setLocation(const Utf8Str &aLocation)
     3347HRESULT Medium::setLocation(const Utf8Str &aLocation, const Utf8Str &aFormat)
    33423348{
    33433349    AssertReturn(!aLocation.isEmpty(), E_FAIL);
     
    34363442                                    tr("Could not find file for the hard disk '%s' (%Rrc)"),
    34373443                                    locationFull.raw(), vrc);
    3438                 else
     3444                else if (aFormat.isEmpty())
    34393445                    return setError(VBOX_E_IPRT_ERROR,
    34403446                                    tr("Could not get the storage format of the hard disk '%s' (%Rrc)"),
    34413447                                    locationFull.raw(), vrc);
     3448                else
     3449                {
     3450                    HRESULT rc = setFormat(Bstr(aFormat));
     3451                    /* setFormat() must not fail since we've just used the backend so
     3452                     * the format object must be there */
     3453                    AssertComRCReturnRC(rc);
     3454                }
    34423455            }
    3443 
    3444             ComAssertRet(backendName != NULL && *backendName != '\0', E_FAIL);
    3445 
    3446             HRESULT rc = setFormat(Bstr(backendName));
    3447             RTStrFree(backendName);
    3448 
    3449             /* setFormat() must not fail since we've just used the backend so
    3450              * the format object must be there */
    3451             AssertComRCReturnRC(rc);
     3456            else
     3457            {
     3458                ComAssertRet(backendName != NULL && *backendName != '\0', E_FAIL);
     3459
     3460                HRESULT rc = setFormat(Bstr(backendName));
     3461                RTStrFree(backendName);
     3462
     3463                /* setFormat() must not fail since we've just used the backend so
     3464                 * the format object must be there */
     3465                AssertComRCReturnRC(rc);
     3466            }
    34523467        }
    34533468
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r23223 r23235  
    11741174                        aLocation,
    11751175                        (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly,
     1176                        DeviceType_HardDisk,
    11761177                        aSetImageId, imageId,
    11771178                        aSetParentId, parentId);
     
    12491250    ComObjPtr<Medium> image;
    12501251    image.createObject();
    1251     rc = image->init (this, aLocation, Medium::OpenReadOnly, true, id, false, Guid());
     1252    rc = image->init (this, aLocation, Medium::OpenReadOnly, DeviceType_DVD, true, id, false, Guid());
    12521253    if (SUCCEEDED(rc))
    12531254    {
     
    13161317    ComObjPtr<Medium> image;
    13171318    image.createObject();
    1318     rc = image->init (this, aLocation, Medium::OpenReadWrite, true, id, false, Guid());
     1319    rc = image->init (this, aLocation, Medium::OpenReadWrite, DeviceType_Floppy, true, id, false, Guid());
    13191320    if (SUCCEEDED(rc))
    13201321    {
  • trunk/src/VBox/Main/include/MediumImpl.h

    r23223 r23235  
    8181                 CBSTR aLocation,
    8282                 HDDOpenMode enOpenMode,
     83                 DeviceType_T aDeviceType,
    8384                 BOOL aSetImageId,
    8485                 const Guid &aImageId,
     
    316317private:
    317318
    318     HRESULT setLocation(const Utf8Str &aLocation);
     319    HRESULT setLocation(const Utf8Str &aLocation, const Utf8Str &aFormat = Utf8Str());
    319320    HRESULT setFormat(CBSTR aFormat);
    320321
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette