VirtualBox

Changeset 24273 in vbox


Ignore:
Timestamp:
Nov 2, 2009 5:36:22 PM (15 years ago)
Author:
vboxsync
Message:

Main: change Medium member variables from Bstr to Utf8 for better debugging and less conversions

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

Legend:

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

    r24271 r24273  
    15011501    if (!mData->mCurrentSnapshot.isNull())
    15021502        return setError(E_FAIL,
    1503                         tr("The snapshot folder of a machine with snapshots cannot be changed (please discard all snapshots first)"));
     1503                        tr("The snapshot folder of a machine with snapshots cannot be changed (please delete all snapshots first)"));
    15041504
    15051505    Utf8Str snapshotFolder = aSnapshotFolder;
     
    21552155            AutoReadLock mediumLock(pMedium);
    21562156            return setError(VBOX_E_OBJECT_IN_USE,
    2157                             tr("Medium '%ls' is already attached to device slot %d on port %d of controller '%ls' of this virtual machine"),
     2157                            tr("Medium '%s' is already attached to device slot %d on port %d of controller '%ls' of this virtual machine"),
    21582158                            pMedium->locationFull().raw(), aDevice, aControllerPort, aControllerName);
    21592159        }
     
    22562256    {
    22572257        return setError(VBOX_E_OBJECT_IN_USE,
    2258                         tr("Medium '%ls' is already attached to this virtual machine"),
     2258                        tr("Medium '%s' is already attached to this virtual machine"),
    22592259                        medium->locationFull().raw());
    22602260    }
     
    56555655                        for (size_t i = 0; i < drivevec.size(); ++i)
    56565656                        {
    5657                             Bstr hostDriveSrc(dev.strHostDriveSrc);
    56585657                            /// @todo eliminate this conversion
    56595658                            ComObjPtr<Medium> med = (Medium *)drivevec[i];
    5660                             if (    hostDriveSrc == med->name()
    5661                                 ||  hostDriveSrc == med->location())
     5659                            if (    dev.strHostDriveSrc == med->name()
     5660                                ||  dev.strHostDriveSrc == med->location())
    56625661                            {
    56635662                                medium = med;
     
    57085707                    if (mType == IsSnapshotMachine)
    57095708                        return setError(E_FAIL,
    5710                                         tr("Immutable hard disk '%ls' with UUID {%RTuuid} cannot be directly attached to snapshot with UUID {%RTuuid} "
     5709                                        tr("Immutable hard disk '%s' with UUID {%RTuuid} cannot be directly attached to snapshot with UUID {%RTuuid} "
    57115710                                           "of the virtual machine '%ls' ('%s')"),
    57125711                                        medium->locationFull().raw(),
     
    57175716
    57185717                    return setError(E_FAIL,
    5719                                     tr("Immutable hard disk '%ls' with UUID {%RTuuid} cannot be directly attached to the virtual machine '%ls' ('%s')"),
     5718                                    tr("Immutable hard disk '%s' with UUID {%RTuuid} cannot be directly attached to the virtual machine '%ls' ('%s')"),
    57205719                                    medium->locationFull().raw(),
    57215720                                    dev.uuid.raw(),
     
    57285727                   )
    57295728                    return setError(E_FAIL,
    5730                                     tr("Hard disk '%ls' with UUID {%RTuuid} cannot be directly attached to the virtual machine '%ls' ('%s') "
     5729                                    tr("Hard disk '%s' with UUID {%RTuuid} cannot be directly attached to the virtual machine '%ls' ('%s') "
    57315730                                       "because it has %d differencing child hard disks"),
    57325731                                    medium->locationFull().raw(),
     
    57395738                                   medium))
    57405739                    return setError(E_FAIL,
    5741                                     tr("Hard disk '%ls' with UUID {%RTuuid} is already attached to the virtual machine '%ls' ('%s')"),
     5740                                    tr("Hard disk '%s' with UUID {%RTuuid} is already attached to the virtual machine '%ls' ('%s')"),
    57425741                                    medium->locationFull().raw(),
    57435742                                    dev.uuid.raw(),
     
    57505749            default:
    57515750                return setError(E_FAIL,
    5752                                 tr("Device with unknown type is attached to the virtual machine '%ls' ('%s')"),
     5751                                tr("Device with unknown type is attached to the virtual machine '%s' ('%s')"),
    57535752                                medium->locationFull().raw(),
    57545753                                mUserData->mName.raw(),
     
    65336532                                    settings::StorageController &data)
    65346533{
    6535     using namespace settings;
    6536 
    65376534    MediaData::AttachmentList atts;
    65386535
     
    65476544        settings::AttachedDevice dev;
    65486545
    6549         dev.deviceType = (*it)->type();
    6550         dev.lPort = (*it)->port();
    6551         dev.lDevice = (*it)->device();
    6552         if (!(*it)->medium().isNull())
     6546        MediumAttachment *pAttach = *it;
     6547        Medium *pMedium = pAttach->medium();
     6548
     6549        dev.deviceType = pAttach->type();
     6550        dev.lPort = pAttach->port();
     6551        dev.lDevice = pAttach->device();
     6552        if (pMedium)
    65536553        {
    65546554            BOOL fHostDrive = false;
    6555             rc = (*it)->medium()->COMGETTER(HostDrive)(&fHostDrive);
     6555            rc = pMedium->COMGETTER(HostDrive)(&fHostDrive);
    65566556            if (FAILED(rc))
    65576557                return rc;
    65586558            if (fHostDrive)
    6559                 dev.strHostDriveSrc = (*it)->medium()->location();
     6559                dev.strHostDriveSrc = pMedium->location();
    65606560            else
    6561                 dev.uuid = (*it)->medium()->id();
    6562             dev.fPassThrough = (*it)->passthrough();
     6561                dev.uuid = pMedium->id();
     6562            dev.fPassThrough = pAttach->passthrough();
    65636563        }
    65646564
     
    89338933            // if we can't access the file here, then we'll be doomed later also, so fail right away
    89348934            setError(E_FAIL, tr("Cannot access state file '%s', runtime error, %Rra"), pSnapshot->stateFilePath().c_str(), irc);
    8935         if (ullSize == 0)
    8936             ullSize = 1;
     8935        if (ullSize == 0) // avoid division by zero
     8936            ullSize = _1M;
    89378937
    89388938        ulStateFileSizeMB = (ULONG)(ullSize / _1M);
    89398939        LogFlowThisFunc(("op %d: saved state file '%s' has %RI64 bytes (%d MB)\n",
    8940                         ulOpCount, pSnapshot->stateFilePath().raw(), ullSize, ulStateFileSizeMB));
     8940                         ulOpCount, pSnapshot->stateFilePath().raw(), ullSize, ulStateFileSizeMB));
    89418941
    89428942        ulTotalWeight += ulStateFileSizeMB;
     
    96239623    if (aSuccess)
    96249624    {
     9625        // new snapshot becomes the current one
    96259626        mData->mCurrentSnapshot = mSnapshotData.mSnapshot;
    96269627
  • trunk/src/VBox/Main/MediumImpl.cpp

    r24258 r24273  
    109109
    110110    const Guid id;
    111     Bstr description;
     111    Utf8Str strDescription;
    112112    MediumState_T state;
    113     Bstr location;
    114     Bstr locationFull;
     113    Utf8Str strLocation;
     114    Utf8Str strLocationFull;
    115115    uint64_t size;
    116     Bstr lastAccessError;
     116    Utf8Str strLastAccessError;
    117117
    118118    BackRefList backRefs;
     
    124124    bool queryInfoRunning : 1;
    125125
    126     const Bstr format;
     126    const Utf8Str strFormat;
    127127    ComObjPtr<MediumFormat> formatObj;
    128128
     
    553553            {
    554554                return setError(E_FAIL,
    555                                 tr("Medium '%ls' involved in the merge operation has more than one child medium (%d)"),
    556                                 aMedium->m->locationFull.raw(),
     555                                tr("Medium '%s' involved in the merge operation has more than one child medium (%d)"),
     556                                aMedium->m->strLocationFull.raw(),
    557557                                aMedium->children().size());
    558558            }
     
    563563            if (aMedium->m->backRefs.size() != 0)
    564564                return setError(E_FAIL,
    565                                 tr("Medium '%ls' is attached to %d virtual machines"),
    566                                 aMedium->m->locationFull.raw(),
     565                                tr("Medium '%s' is attached to %d virtual machines"),
     566                                aMedium->m->strLocationFull.raw(),
    567567                                aMedium->m->backRefs.size());
    568568        }
     
    572572            if (aMedium->m->type == MediumType_Immutable)
    573573                return setError(E_FAIL,
    574                                 tr("Medium '%ls' is immutable"),
    575                                 aMedium->m->locationFull.raw());
     574                                tr("Medium '%s' is immutable"),
     575                                aMedium->m->strLocationFull.raw());
    576576        }
    577577
     
    10301030        if (m->state == MediumState_Inaccessible)
    10311031        {
    1032             Assert(!m->lastAccessError.isEmpty());
    1033             rc = setError(E_FAIL, Utf8Str(m->lastAccessError));
     1032            Assert(!m->strLastAccessError.isEmpty());
     1033            rc = setError(E_FAIL, m->strLastAccessError);
    10341034        }
    10351035        else
     
    10381038
    10391039            /* storage format must be detected by queryInfo() if the medium is accessible */
    1040             AssertReturn(!m->format.isNull(), E_FAIL);
     1040            AssertReturn(!m->strFormat.isEmpty(), E_FAIL);
    10411041        }
    10421042    }
     
    10941094     * as inaccessible for now */
    10951095    m->state = MediumState_Inaccessible;
    1096     m->lastAccessError = tr("Accessibility check was not yet performed");
     1096    m->strLastAccessError = tr("Accessibility check was not yet performed");
    10971097
    10981098    /* required */
     
    11031103
    11041104    /* optional */
    1105     m->description = data.strDescription;
     1105    m->strDescription = data.strDescription;
    11061106
    11071107    /* required */
     
    11571157    m->devType = aDeviceType;
    11581158
    1159     LogFlowThisFunc(("m->locationFull='%ls', m->format=%ls, m->id={%RTuuid}\n",
    1160                      m->locationFull.raw(), m->format.raw(), m->id.raw()));
     1159    LogFlowThisFunc(("m->locationFull='%s', m->format=%s, m->id={%RTuuid}\n",
     1160                     m->strLocationFull.raw(), m->strFormat.raw(), m->id.raw()));
    11611161
    11621162    /* Don't call queryInfo() for registered media to prevent the calling
     
    12471247    rc = setLocation(aLocation);
    12481248    CheckComRCReturnRC(rc);
    1249     m->description = aDescription;
     1249    m->strDescription = aDescription;
    12501250
    12511251/// @todo generate uuid (similarly to host network interface uuid) from location and device type
     
    13401340    AutoReadLock alock(this);
    13411341
    1342     if (m->description.isEmpty())
     1342    if (m->strDescription.isEmpty())
    13431343        Bstr("").cloneTo(aDescription);
    13441344    else
    1345         m->description.cloneTo(aDescription);
     1345        m->strDescription.cloneTo(aDescription);
    13461346
    13471347    return S_OK;
     
    13871387    AutoReadLock alock(this);
    13881388
    1389     m->locationFull.cloneTo(aLocation);
     1389    m->strLocationFull.cloneTo(aLocation);
    13901390
    13911391    return S_OK;
     
    14781478
    14791479    /* no need to lock, m->format is const */
    1480     m->format.cloneTo(aFormat);
     1480    m->strFormat.cloneTo(aFormat);
    14811481
    14821482    return S_OK;
     
    15271527    if (!mParent.isNull())
    15281528        return setError(E_FAIL,
    1529                         tr("Hard disk '%ls' is a differencing hard disk"),
    1530                 m->locationFull.raw());
     1529                        tr("Hard disk '%s' is a differencing hard disk"),
     1530                        m->strLocationFull.raw());
    15311531
    15321532    /* cannot change the type of a hard disk being in use */
    15331533    if (m->backRefs.size() != 0)
    15341534        return setError(E_FAIL,
    1535                         tr("Hard disk '%ls' is attached to %d virtual machines"),
    1536                         m->locationFull.raw(), m->backRefs.size());
     1535                        tr("Hard disk '%s' is attached to %d virtual machines"),
     1536                        m->strLocationFull.raw(), m->backRefs.size());
    15371537
    15381538    switch (aType)
     
    16831683    if (mParent.isNull())
    16841684        return setError(VBOX_E_NOT_SUPPORTED,
    1685                         tr("Hard disk '%ls' is not differencing"),
    1686                         m->locationFull.raw());
     1685                        tr("Hard disk '%s' is not differencing"),
     1686                        m->strLocationFull.raw());
    16871687
    16881688    if (m->autoReset != aAutoReset)
     
    17041704    AutoReadLock alock(this);
    17051705
    1706     if (m->lastAccessError.isEmpty())
     1706    if (m->strLastAccessError.isEmpty())
    17071707        Bstr("").cloneTo(aLastAccessError);
    17081708    else
    1709         m->lastAccessError.cloneTo(aLastAccessError);
     1709        m->strLastAccessError.cloneTo(aLastAccessError);
    17101710
    17111711    return S_OK;
     
    19081908            LogFlowThisFunc(("Failing - state=%d\n", m->state));
    19091909            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    1910                           tr ("Medium '%ls' is not locked for reading"),
    1911                           m->locationFull.raw());
     1910                          tr ("Medium '%s' is not locked for reading"),
     1911                          m->strLocationFull.raw());
    19121912            break;
    19131913        }
     
    19931993            LogFlowThisFunc(("Failing - state=%d\n", m->state));
    19941994            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    1995                           tr ("Medium '%ls' is not locked for writing"),
    1996                           m->locationFull.raw());
     1995                          tr ("Medium '%s' is not locked for writing"),
     1996                          m->strLocationFull.raw());
    19971997            break;
    19981998        }
     
    20392039    if (m->backRefs.size() != 0)
    20402040        return setError(VBOX_E_OBJECT_IN_USE,
    2041                         tr("Medium '%ls' is attached to %d virtual machines"),
    2042                         m->locationFull.raw(), m->backRefs.size());
     2041                        tr("Medium '%s' is attached to %d virtual machines"),
     2042                        m->strLocationFull.raw(), m->backRefs.size());
    20432043
    20442044    /* perform extra media-dependent close checks */
     
    22152215        &&  !(m->formatObj->capabilities() & MediumFormatCapabilities_CreateDynamic))
    22162216        return setError(VBOX_E_NOT_SUPPORTED,
    2217                         tr("Hard disk format '%ls' does not support dynamic storage creation"),
    2218                         m->format.raw());
     2217                        tr("Hard disk format '%s' does not support dynamic storage creation"),
     2218                        m->strFormat.raw());
    22192219    if (    (aVariant & MediumVariant_Fixed)
    22202220        &&  !(m->formatObj->capabilities() & MediumFormatCapabilities_CreateDynamic))
    22212221        return setError(VBOX_E_NOT_SUPPORTED,
    2222                         tr("Hard disk format '%ls' does not support fixed storage creation"),
    2223                         m->format.raw());
     2222                        tr("Hard disk format '%s' does not support fixed storage creation"),
     2223                        m->strFormat.raw());
    22242224
    22252225    switch (m->state)
     
    22362236    HRESULT rc = progress->init(mVirtualBox, static_cast<IMedium*>(this),
    22372237        (aVariant & MediumVariant_Fixed)
    2238           ? BstrFmt(tr("Creating fixed hard disk storage unit '%ls'"), m->locationFull.raw())
    2239           : BstrFmt(tr("Creating dynamic hard disk storage unit '%ls'"), m->locationFull.raw()),
     2238          ? BstrFmt(tr("Creating fixed hard disk storage unit '%s'"), m->strLocationFull.raw())
     2239          : BstrFmt(tr("Creating dynamic hard disk storage unit '%s'"), m->strLocationFull.raw()),
    22402240        TRUE /* aCancelable */);
    22412241    CheckComRCReturnRC(rc);
     
    23022302    if (m->type == MediumType_Writethrough)
    23032303        return setError(E_FAIL,
    2304                         tr("Hard disk '%ls' is Writethrough"),
    2305                         m->locationFull.raw());
     2304                        tr("Hard disk '%s' is Writethrough"),
     2305                        m->strLocationFull.raw());
    23062306
    23072307    /* We want to be locked for reading as long as our diff child is being
     
    24132413        progress.createObject();
    24142414        rc = progress->init(mVirtualBox, static_cast <IMedium *>(this),
    2415             BstrFmt(tr("Creating clone hard disk '%ls'"),
    2416                     target->m->locationFull.raw()),
     2415            BstrFmt(tr("Creating clone hard disk '%s'"),
     2416                    target->m->strLocationFull.raw()),
    24172417            TRUE /* aCancelable */);
    24182418        CheckComRCThrowRC(rc);
     
    24882488        progress.createObject();
    24892489        rc = progress->init(mVirtualBox, static_cast <IMedium *>(this),
    2490              BstrFmt(tr("Compacting hard disk '%ls'"), m->locationFull.raw()),
     2490             BstrFmt(tr("Compacting hard disk '%s'"), m->strLocationFull.raw()),
    24912491             TRUE /* aCancelable */);
    24922492        CheckComRCThrowRC(rc);
     
    25432543    if (mParent.isNull())
    25442544        return setError(VBOX_E_NOT_SUPPORTED,
    2545                         tr ("Hard disk '%ls' is not differencing"),
    2546                         m->locationFull.raw());
     2545                        tr ("Hard disk '%s' is not differencing"),
     2546                        m->strLocationFull.raw());
    25472547
    25482548    HRESULT rc = canClose();
     
    25582558        progress.createObject();
    25592559        rc = progress->init(mVirtualBox, static_cast <IMedium *>(this),
    2560             BstrFmt(tr("Resetting differencing hard disk '%ls'"),
    2561                      m->locationFull.raw()),
     2560            BstrFmt(tr("Resetting differencing hard disk '%s'"),
     2561                     m->strLocationFull.raw()),
    25622562            FALSE /* aCancelable */);
    25632563        CheckComRCThrowRC(rc);
     
    26202620    AutoWriteLock alock(this);
    26212621
    2622     LogFlowThisFunc(("locationFull.before='%s'\n", m->locationFull.raw()));
    2623 
    2624     Utf8Str path = m->locationFull;
     2622    LogFlowThisFunc(("locationFull.before='%s'\n", m->strLocationFull.raw()));
     2623
     2624    Utf8Str path = m->strLocationFull;
    26252625
    26262626    if (RTPathStartsWith(path.c_str(), aOldPath))
     
    26322632        mVirtualBox->calculateRelativePath(path, path);
    26332633
    2634         unconst(m->locationFull) = newPath;
    2635         unconst(m->location) = path;
    2636 
    2637         LogFlowThisFunc(("locationFull.after='%s'\n", m->locationFull.raw()));
     2634        unconst(m->strLocationFull) = newPath;
     2635        unconst(m->strLocation) = path;
     2636
     2637        LogFlowThisFunc(("locationFull.after='%s'\n", m->strLocationFull.raw()));
    26382638    }
    26392639
     
    26722672    if (m->numCreateDiffTasks > 0)
    26732673        return setError(E_FAIL,
    2674                         tr("One or more differencing child hard disks are being created for the hard disk '%ls' (%u)"),
    2675                         m->locationFull.raw(), m->numCreateDiffTasks);
     2674                        tr("One or more differencing child hard disks are being created for the hard disk '%s' (%u)"),
     2675                        m->strLocationFull.raw(), m->numCreateDiffTasks);
    26762676
    26772677    BackRefList::iterator it =
     
    27722772 * @return
    27732773 */
    2774 const Bstr& Medium::location() const
    2775 {
    2776     return m->location;
     2774const Utf8Str& Medium::location() const
     2775{
     2776    return m->strLocation;
    27772777}
    27782778
     
    27812781 * @return
    27822782 */
    2783 const Bstr& Medium::locationFull() const
    2784 {
    2785     return m->locationFull;
     2783const Utf8Str& Medium::locationFull() const
     2784{
     2785    return m->strLocationFull;
    27862786}
    27872787
     
    29732973
    29742974    data.uuid = m->id;
    2975     data.strLocation = m->location;
    2976     data.strFormat = m->format;
     2975    data.strLocation = m->strLocation;
     2976    data.strFormat = m->strFormat;
    29772977
    29782978    /* optional, only for diffs, default is false */
     
    29832983
    29842984    /* optional */
    2985     data.strDescription = m->description;
     2985    data.strDescription = m->strDescription;
    29862986
    29872987    /* optional properties */
     
    30373037    AutoReadLock alock(this);
    30383038
    3039     Utf8Str locationFull(m->locationFull);
     3039    Utf8Str locationFull(m->strLocationFull);
    30403040
    30413041    /// @todo NEWMEDIA delegate the comparison to the backend?
     
    31313131    if (children().size() > 1)
    31323132        return setError(E_FAIL,
    3133                         tr ("Hard disk '%ls' has more than one child hard disk (%d)"),
    3134                         m->locationFull.raw(), children().size());
     3133                        tr ("Hard disk '%s' has more than one child hard disk (%d)"),
     3134                        m->strLocationFull.raw(), children().size());
    31353135
    31363136    /* this is a read-only hard disk with children; it must be associated with
     
    33293329Bstr Medium::preferredDiffFormat()
    33303330{
    3331     Bstr format;
     3331    Utf8Str strFormat;
    33323332
    33333333    AutoCaller autoCaller(this);
    3334     AssertComRCReturn(autoCaller.rc(), format);
     3334    AssertComRCReturn(autoCaller.rc(), strFormat);
    33353335
    33363336    /* m->format is const, no need to lock */
    3337     format = m->format;
     3337    strFormat = m->strFormat;
    33383338
    33393339    /* check that our own format supports diffs */
     
    33423342        /* use the default format if not */
    33433343        AutoReadLock propsLock(mVirtualBox->systemProperties());
    3344         format = mVirtualBox->getDefaultHardDiskFormat();
    3345     }
    3346 
    3347     return format;
     3344        strFormat = mVirtualBox->getDefaultHardDiskFormat();
     3345    }
     3346
     3347    return strFormat;
    33483348}
    33493349
     
    33843384Utf8Str Medium::name()
    33853385{
    3386     Utf8Str location(m->locationFull);
     3386    Utf8Str location(m->strLocationFull);
    33873387
    33883388    Utf8Str name = RTPathFilename(location.c_str());
     
    33913391
    33923392/**
    3393  * Sets the value of m->location and calculates the value of m->locationFull.
     3393 * Sets the value of m->strLocation and calculates the value of m->strLocationFull.
    33943394 *
    33953395 * Treats non-FS-path locations specially, and prepends the default hard disk
     
    34203420    /* formatObj may be null only when initializing from an existing path and
    34213421     * no format is known yet */
    3422     AssertReturn((!m->format.isNull() && !m->formatObj.isNull()) ||
    3423                  (autoCaller.state() == InInit &&
    3424                   m->state != MediumState_NotCreated && m->id.isEmpty() &&
    3425                   m->format.isNull() && m->formatObj.isNull()),
     3422    AssertReturn(    (!m->strFormat.isEmpty() && !m->formatObj.isNull())
     3423                  || (    autoCaller.state() == InInit
     3424                       && m->state != MediumState_NotCreated
     3425                       && m->id.isEmpty()
     3426                       && m->strFormat.isEmpty()
     3427                       && m->formatObj.isNull()),
    34263428                 E_FAIL);
    34273429
    34283430    /* are we dealing with a new medium constructed using the existing
    34293431     * location? */
    3430     bool isImport = m->format.isNull();
     3432    bool isImport = m->strFormat.isEmpty();
    34313433
    34323434    if (   isImport
     
    35373539        if (m->formatObj->capabilities() & MediumFormatCapabilities_File)
    35383540        {
    3539             m->location = location;
    3540             m->locationFull = locationFull;
     3541            m->strLocation = location;
     3542            m->strLocationFull = locationFull;
    35413543
    35423544            if (m->state == MediumState_NotCreated)
     
    35513553        else
    35523554        {
    3553             m->location = locationFull;
    3554             m->locationFull = locationFull;
     3555            m->strLocation = locationFull;
     3556            m->strLocationFull = locationFull;
    35553557        }
    35563558    }
    35573559    else
    35583560    {
    3559         m->location = aLocation;
    3560         m->locationFull = aLocation;
     3561        m->strLocation = aLocation;
     3562        m->strLocationFull = aLocation;
    35613563    }
    35623564
     
    36373639     * you do with the contents of this medium object, as you will
    36383640     * create races if there are concurrent changes. */
    3639     Utf8Str format(m->format);
    3640     Utf8Str location(m->locationFull);
     3641    Utf8Str format(m->strFormat);
     3642    Utf8Str location(m->strLocationFull);
    36413643    ComObjPtr<MediumFormat> formatObj = m->formatObj;
    36423644
     
    37223724                    {
    37233725                        lastAccessError = Utf8StrFmt(
    3724                             tr("UUID {%RTuuid} of the medium '%s' does not match the value {%RTuuid} stored in the media registry ('%ls')"),
    3725                             &uuid, location.c_str(), mediumId.raw(),
    3726                             mVirtualBox->settingsFilePath().raw());
     3726                            tr("UUID {%RTuuid} of the medium '%s' does not match the value {%RTuuid} stored in the media registry ('%s')"),
     3727                            &uuid,
     3728                            location.c_str(),
     3729                            mediumId.raw(),
     3730                            mVirtualBox->settingsFilePath().c_str());
    37273731                        throw S_OK;
    37283732                    }
     
    37723776                    {
    37733777                        lastAccessError = Utf8StrFmt(
    3774                             tr("Parent hard disk with UUID {%RTuuid} of the hard disk '%s' is not found in the media registry ('%ls')"),
     3778                            tr("Parent hard disk with UUID {%RTuuid} of the hard disk '%s' is not found in the media registry ('%s')"),
    37753779                            &parentId, location.c_str(),
    3776                             mVirtualBox->settingsFilePath().raw());
     3780                            mVirtualBox->settingsFilePath().c_str());
    37773781                        throw S_OK;
    37783782                    }
     
    38013805                    {
    38023806                        lastAccessError = Utf8StrFmt(
    3803                             tr("Hard disk '%s' is differencing but it is not associated with any parent hard disk in the media registry ('%ls')"),
     3807                            tr("Hard disk '%s' is differencing but it is not associated with any parent hard disk in the media registry ('%s')"),
    38043808                            location.c_str(),
    3805                             mVirtualBox->settingsFilePath().raw());
     3809                            mVirtualBox->settingsFilePath().c_str());
    38063810                        throw S_OK;
    38073811                    }
     
    38123816                    {
    38133817                        lastAccessError = Utf8StrFmt(
    3814                             tr ("Parent UUID {%RTuuid} of the hard disk '%s' does not match UUID {%RTuuid} of its parent hard disk stored in the media registry ('%ls')"),
     3818                            tr ("Parent UUID {%RTuuid} of the hard disk '%s' does not match UUID {%RTuuid} of its parent hard disk stored in the media registry ('%s')"),
    38153819                            &parentId, location.c_str(),
    38163820                            mParent->id().raw(),
    3817                             mVirtualBox->settingsFilePath().raw());
     3821                            mVirtualBox->settingsFilePath().c_str());
    38183822                        throw S_OK;
    38193823                    }
     
    38523856        m->size = mediumSize;
    38533857        m->logicalSize = mediumLogicalSize;
    3854         m->lastAccessError.setNull();
     3858        m->strLastAccessError.setNull();
    38553859    }
    38563860    else
    38573861    {
    3858         m->lastAccessError = lastAccessError;
    3859         LogWarningFunc(("'%s' is not accessible (error='%ls', rc=%Rhrc, vrc=%Rrc)\n",
    3860                          location.c_str(), m->lastAccessError.raw(),
     3862        m->strLastAccessError = lastAccessError;
     3863        LogWarningFunc(("'%s' is not accessible (error='%s', rc=%Rhrc, vrc=%Rrc)\n",
     3864                         location.c_str(), m->strLastAccessError.c_str(),
    38613865                         rc, vrc));
    38623866    }
     
    38953899        {
    38963900            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3897                           tr("Storage for the medium '%ls' is not created"),
    3898                           m->locationFull.raw());
     3901                          tr("Storage for the medium '%s' is not created"),
     3902                          m->strLocationFull.raw());
    38993903            break;
    39003904        }
     
    39023906        {
    39033907            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3904                           tr("Storage for the medium '%ls' is already created"),
    3905                           m->locationFull.raw());
     3908                          tr("Storage for the medium '%s' is already created"),
     3909                          m->strLocationFull.raw());
    39063910            break;
    39073911        }
     
    39093913        {
    39103914            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3911                           tr("Medium '%ls' is locked for reading by another task"),
    3912                           m->locationFull.raw());
     3915                          tr("Medium '%s' is locked for reading by another task"),
     3916                          m->strLocationFull.raw());
    39133917            break;
    39143918        }
     
    39163920        {
    39173921            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3918                           tr("Medium '%ls' is locked for writing by another task"),
    3919                           m->locationFull.raw());
     3922                          tr("Medium '%s' is locked for writing by another task"),
     3923                          m->strLocationFull.raw());
    39203924            break;
    39213925        }
    39223926        case MediumState_Inaccessible:
    39233927        {
    3924             AssertMsg(!m->lastAccessError.isEmpty(),
    3925                       ("There must always be a reason for Inaccessible"));
    3926 
    39273928            /* be in sync with Console::powerUpThread() */
    3928             if (!m->lastAccessError.isEmpty())
     3929            if (!m->strLastAccessError.isEmpty())
    39293930                rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3930                               tr("Medium '%ls' is not accessible. %ls"),
    3931                               m->locationFull.raw(), m->lastAccessError.raw());
     3931                              tr("Medium '%s' is not accessible. %s"),
     3932                              m->strLocationFull.raw(), m->strLastAccessError.c_str());
    39323933            else
    39333934                rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3934                               tr("Medium '%ls' is not accessible"),
    3935                               m->locationFull.raw());
     3935                              tr("Medium '%s' is not accessible"),
     3936                              m->strLocationFull.raw());
    39363937            break;
    39373938        }
     
    39393940        {
    39403941            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3941                           tr("Storage for the medium '%ls' is being created"),
    3942                           m->locationFull.raw(), m->lastAccessError.raw());
     3942                          tr("Storage for the medium '%s' is being created"),
     3943                          m->strLocationFull.raw());
    39433944            break;
    39443945        }
     
    39463947        {
    39473948            rc = setError(VBOX_E_INVALID_OBJECT_STATE,
    3948                           tr("Storage for the medium '%ls' is being deleted"),
    3949                           m->locationFull.raw(), m->lastAccessError.raw());
     3949                          tr("Storage for the medium '%s' is being deleted"),
     3950                          m->strLocationFull.raw());
    39503951            break;
    39513952        }
     
    39994000                                               | MediumFormatCapabilities_CreateFixed)))
    40004001        return setError(VBOX_E_NOT_SUPPORTED,
    4001                         tr("Hard disk format '%ls' does not support storage deletion"),
    4002                         m->format.raw());
     4002                        tr("Hard disk format '%s' does not support storage deletion"),
     4003                        m->strFormat.raw());
    40034004
    40044005    /* Note that we are fine with Inaccessible state too: a) for symmetry with
     
    40204021    if (m->backRefs.size() != 0)
    40214022        return setError(VBOX_E_OBJECT_IN_USE,
    4022                         tr("Hard disk '%ls' is attached to %d virtual machines"),
    4023                         m->locationFull.raw(), m->backRefs.size());
     4023                        tr("Hard disk '%s' is attached to %d virtual machines"),
     4024                        m->strLocationFull.raw(), m->backRefs.size());
    40244025
    40254026    HRESULT rc = canClose();
     
    40594060            progress.createObject();
    40604061            rc = progress->init(mVirtualBox, static_cast<IMedium*>(this),
    4061                 BstrFmt(tr("Deleting hard disk storage unit '%ls'"),
    4062                          m->locationFull.raw()),
     4062                BstrFmt(tr("Deleting hard disk storage unit '%s'"),
     4063                         m->strLocationFull.raw()),
    40634064                FALSE /* aCancelable */);
    40644065            CheckComRCReturnRC(rc);
     
    41774178            {
    41784179                return setError(VBOX_E_INVALID_OBJECT_STATE,
    4179                                 tr("Hard disk '%ls' is attached to a virtual machine with UUID {%RTuuid}. No differencing hard disks based on it may be created until it is detached"),
    4180                                 m->locationFull.raw(), it->machineId.raw());
     4180                                tr("Hard disk '%s' is attached to a virtual machine with UUID {%RTuuid}. No differencing hard disks based on it may be created until it is detached"),
     4181                                m->strLocationFull.raw(), it->machineId.raw());
    41814182            }
    41824183
     
    41974198            progress.createObject();
    41984199            rc = progress->init(mVirtualBox, static_cast<IMedium*>(this),
    4199                 BstrFmt(tr("Creating differencing hard disk storage unit '%ls'"),
    4200                          aTarget->m->locationFull.raw()),
     4200                BstrFmt(tr("Creating differencing hard disk storage unit '%s'"),
     4201                         aTarget->m->strLocationFull.raw()),
    42014202                TRUE /* aCancelable */);
    42024203            CheckComRCReturnRC(rc);
     
    43044305            else
    43054306            {
    4306                 Bstr tgtLoc;
     4307                Utf8Str tgtLoc;
    43074308                {
    43084309                    AutoReadLock alock(this);
     
    43124313                AutoReadLock alock(this);
    43134314                return setError(E_FAIL,
    4314                                 tr("Hard disks '%ls' and '%ls' are unrelated"),
    4315                                 m->locationFull.raw(), tgtLoc.raw());
     4315                                tr("Hard disks '%s' and '%s' are unrelated"),
     4316                                m->strLocationFull.raw(), tgtLoc.raw());
    43164317            }
    43174318        }
     
    45454546    }
    45464547
    4547     unconst(m->format) = aFormat;
     4548    unconst(m->strFormat) = aFormat;
    45484549
    45494550    return S_OK;
     
    48464847                ComAssertRCThrow(vrc, E_FAIL);
    48474848
    4848                 Utf8Str format(that->m->format);
    4849                 Utf8Str location(that->m->locationFull);
     4849                Utf8Str format(that->m->strFormat);
     4850                Utf8Str location(that->m->strLocationFull);
    48504851                /* uint64_t capabilities = */ that->m->formatObj->capabilities();
    48514852
     
    49494950
    49504951                Guid id = that->m->id;
    4951                 Utf8Str format(that->m->format);
    4952                 Utf8Str location(that->m->locationFull);
    4953 
    4954                 Utf8Str targetFormat(target->m->format);
    4955                 Utf8Str targetLocation(target->m->locationFull);
     4952                Utf8Str format(that->m->strFormat);
     4953                Utf8Str location(that->m->strLocationFull);
     4954
     4955                Utf8Str targetFormat(target->m->strFormat);
     4956                Utf8Str targetLocation(target->m->strLocationFull);
    49564957
    49574958                Assert(target->m->state == MediumState_Creating);
     
    51425143                        /* open the first image with VDOPEN_FLAGS_INFO because
    51435144                         * it's not necessarily the base one */
    5144                         vrc = VDOpen(hdd, Utf8Str((*it)->m->format).c_str(),
    5145                                       Utf8Str((*it)->m->locationFull).c_str(),
     5145                        vrc = VDOpen(hdd, (*it)->m->strFormat.c_str(),
     5146                                      (*it)->m->strLocationFull.c_str(),
    51465147                                      it == chain->begin() ?
    51475148                                          VD_OPEN_FLAGS_INFO : 0,
     
    51505151                            throw vrc;
    51515152#if 0
    5152                         LogFlow(("*** MERGE disk = %ls\n", (*it)->m->locationFull.raw()));
     5153                        LogFlow(("*** MERGE disk = %s\n", (*it)->m->strLocationFull.raw()));
    51535154#endif
    51545155                    }
     
    51935194                            {
    51945195                                /* VD_OPEN_FLAGS_INFO since UUID is wrong yet */
    5195                                 vrc = VDOpen(hdd, Utf8Str((*it)->m->format).c_str(),
    5196                                              Utf8Str((*it)->m->locationFull).c_str(),
     5196                                vrc = VDOpen(hdd, (*it)->m->strFormat.c_str(),
     5197                                             (*it)->m->strLocationFull.c_str(),
    51975198                                             VD_OPEN_FLAGS_INFO,
    51985199                                             (*it)->m->vdDiskIfaces);
     
    52165217                {
    52175218                    throw setError(E_FAIL,
    5218                                    tr("Could not merge the hard disk '%ls' to '%ls'%s"),
    5219                                    chain->source()->m->locationFull.raw(),
    5220                                    chain->target()->m->locationFull.raw(),
     5219                                   tr("Could not merge the hard disk '%s' to '%s'%s"),
     5220                                   chain->source()->m->strLocationFull.raw(),
     5221                                   chain->target()->m->strLocationFull.raw(),
    52215222                                   that->vdError(aVRC).raw());
    52225223                }
     
    54335434
    54345435                        /** Open all images in read-only mode. */
    5435                         vrc = VDOpen(hdd, Utf8Str((*it)->m->format).c_str(),
    5436                                      Utf8Str((*it)->m->locationFull).c_str(),
     5436                        vrc = VDOpen(hdd, (*it)->m->strFormat.c_str(),
     5437                                     (*it)->m->strLocationFull.c_str(),
    54375438                                     VD_OPEN_FLAGS_READONLY,
    54385439                                     (*it)->m->vdDiskIfaces);
     
    54415442                            throw setError(E_FAIL,
    54425443                                           tr("Could not open the hard disk storage unit '%s'%s"),
    5443                                            Utf8Str((*it)->m->locationFull).raw(),
     5444                                           (*it)->m->strLocationFull.raw(),
    54445445                                           that->vdError(vrc).raw());
    54455446                        }
     
    54495450                    thatLock.leave();
    54505451
    5451                     Utf8Str targetFormat(target->m->format);
    5452                     Utf8Str targetLocation(target->m->locationFull);
     5452                    Utf8Str targetFormat(target->m->strFormat);
     5453                    Utf8Str targetLocation(target->m->strLocationFull);
    54535454
    54545455                    Assert(    target->m->state == MediumState_Creating
     
    54795480
    54805481                            /* Open all images in appropriate mode. */
    5481                             vrc = VDOpen(targetHdd, Utf8Str((*it)->m->format).c_str(),
    5482                                          Utf8Str((*it)->m->locationFull).c_str(),
     5482                            vrc = VDOpen(targetHdd, (*it)->m->strFormat.c_str(),
     5483                                         (*it)->m->strLocationFull.c_str(),
    54835484                                         ((*it)->m->state == MediumState_LockedWrite) ? VD_OPEN_FLAGS_NORMAL : VD_OPEN_FLAGS_READONLY,
    54845485                                         (*it)->m->vdDiskIfaces);
     
    54875488                                throw setError(E_FAIL,
    54885489                                               tr("Could not open the hard disk storage unit '%s'%s"),
    5489                                                Utf8Str((*it)->m->locationFull).raw(),
     5490                                               (*it)->m->strLocationFull.raw(),
    54905491                                               that->vdError(vrc).raw());
    54915492                            }
     
    56085609                ComAssertRCThrow(vrc, E_FAIL);
    56095610
    5610                 Utf8Str format(that->m->format);
    5611                 Utf8Str location(that->m->locationFull);
     5611                Utf8Str format(that->m->strFormat);
     5612                Utf8Str location(that->m->strLocationFull);
    56125613
    56135614                /* unlock before the potentially lengthy operation */
     
    56705671
    56715672                Guid id = that->m->id;
    5672                 Utf8Str format(that->m->format);
    5673                 Utf8Str location(that->m->locationFull);
     5673                Utf8Str format(that->m->strFormat);
     5674                Utf8Str location(that->m->strLocationFull);
    56745675
    56755676                Guid parentId = that->mParent->m->id;
    5676                 Utf8Str parentFormat(that->mParent->m->format);
    5677                 Utf8Str parentLocation(that->mParent->m->locationFull);
     5677                Utf8Str parentFormat(that->mParent->m->strFormat);
     5678                Utf8Str parentLocation(that->mParent->m->strLocationFull);
    56785679
    56795680                Assert(that->m->state == MediumState_LockedWrite);
     
    57895790
    57905791                        /** Open all images but last in read-only mode. */
    5791                         vrc = VDOpen(hdd, Utf8Str((*it)->m->format).c_str(),
    5792                                      Utf8Str((*it)->m->locationFull).c_str(),
     5792                        vrc = VDOpen(hdd, (*it)->m->strFormat.c_str(),
     5793                                     (*it)->m->strLocationFull.c_str(),
    57935794                                     (it == last) ? VD_OPEN_FLAGS_NORMAL : VD_OPEN_FLAGS_READONLY,
    57945795                                     (*it)->m->vdDiskIfaces);
     
    57975798                            throw setError(E_FAIL,
    57985799                                           tr("Could not open the hard disk storage unit '%s'%s"),
    5799                                            Utf8Str((*it)->m->locationFull).raw(),
     5800                                           (*it)->m->strLocationFull.raw(),
    58005801                                           that->vdError(vrc).raw());
    58015802                        }
     
    58185819                        if (vrc == VERR_NOT_SUPPORTED)
    58195820                            throw setError(VBOX_E_NOT_SUPPORTED,
    5820                                            tr("Compacting is not supported yet for hard disk '%s'"),
    5821                                            Utf8Str(that->m->locationFull).raw());
     5821                                           tr("Compacting is not yet supported for hard disk '%s'"),
     5822                                           that->m->strLocationFull.raw());
    58225823                        else if (vrc == VERR_NOT_IMPLEMENTED)
    58235824                            throw setError(E_NOTIMPL,
    58245825                                           tr("Compacting is not implemented, hard disk '%s'"),
    5825                                            Utf8Str(that->m->locationFull).raw());
     5826                                           that->m->strLocationFull.raw());
    58265827                        else
    58275828                            throw setError(E_FAIL,
    58285829                                           tr("Could not compact hard disk '%s'%s"),
    5829                                            Utf8Str(that->m->locationFull).raw(),
     5830                                           that->m->strLocationFull.raw(),
    58305831                                           that->vdError(vrc).raw());
    58315832                    }
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r24079 r24273  
    27822782                (aLocation != NULL &&
    27832783                 RTPathCompare(location.c_str(),
    2784                                Utf8Str((*it)->locationFull()).c_str()
     2784                               (*it)->locationFull().c_str()
    27852785                              ) == 0);
    27862786        if (found)
     
    28582858                (aLocation != NULL &&
    28592859                 RTPathCompare(location.c_str(),
    2860                                Utf8Str((*it)->locationFull()).c_str()
     2860                               (*it)->locationFull().c_str()
    28612861                              ) == 0);
    28622862        if (found)
     
    30483048 */
    30493049HRESULT VirtualBox::checkMediaForConflicts2 (const Guid &aId,
    3050                                              const Bstr &aLocation,
     3050                                             const Utf8Str &aLocation,
    30513051                                             Utf8Str &aConflict)
    30523052{
     
    30593059    HRESULT rc = S_OK;
    30603060
     3061    Bstr bstrLocation(aLocation);
     3062
    30613063    {
    30623064        ComObjPtr<Medium> hardDisk;
    3063         rc = findHardDisk(&aId, aLocation, false /* aSetError */, &hardDisk);
     3065        rc = findHardDisk(&aId, bstrLocation, false /* aSetError */, &hardDisk);
    30643066        if (SUCCEEDED(rc))
    30653067        {
     
    30673069            AutoReadLock mediaLock (hardDisk);
    30683070            aConflict = Utf8StrFmt (
    3069                 tr ("hard disk '%ls' with UUID {%RTuuid}"),
     3071                tr ("hard disk '%s' with UUID {%RTuuid}"),
    30703072                hardDisk->locationFull().raw(), hardDisk->id().raw());
    30713073            return S_OK;
     
    30753077    {
    30763078        ComObjPtr<Medium> image;
    3077         rc = findDVDImage (&aId, aLocation, false /* aSetError */, &image);
     3079        rc = findDVDImage (&aId, bstrLocation, false /* aSetError */, &image);
    30783080        if (SUCCEEDED(rc))
    30793081        {
     
    30813083            AutoReadLock mediaLock (image);
    30823084            aConflict = Utf8StrFmt (
    3083                 tr ("CD/DVD image '%ls' with UUID {%RTuuid}"),
     3085                tr ("CD/DVD image '%s' with UUID {%RTuuid}"),
    30843086                image->locationFull().raw(), image->id().raw());
    30853087            return S_OK;
     
    30893091    {
    30903092        ComObjPtr<Medium> image;
    3091         rc = findFloppyImage(&aId, aLocation, false /* aSetError */, &image);
     3093        rc = findFloppyImage(&aId, bstrLocation, false /* aSetError */, &image);
    30923094        if (SUCCEEDED(rc))
    30933095        {
     
    30953097            AutoReadLock mediaLock (image);
    30963098            aConflict = Utf8StrFmt (
    3097                 tr ("floppy image '%ls' with UUID {%RTuuid}"),
     3099                tr ("floppy image '%s' with UUID {%RTuuid}"),
    30983100                image->locationFull().raw(), image->id().raw());
    30993101            return S_OK;
  • trunk/src/VBox/Main/include/MediumImpl.h

    r24258 r24273  
    165165    const Guid& id() const;
    166166    MediumState_T state() const;
    167     const Bstr& location() const;
    168     const Bstr& locationFull() const;
     167    const Utf8Str& location() const;
     168    const Utf8Str& locationFull() const;
    169169
    170170    const Guid* getFirstMachineBackrefId() const;
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r23327 r24273  
    277277private:
    278278
    279     HRESULT checkMediaForConflicts2(const Guid &aId, const Bstr &aLocation,
     279    HRESULT checkMediaForConflicts2(const Guid &aId, const Utf8Str &aLocation,
    280280                                    Utf8Str &aConflictType);
    281281
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