VirtualBox

Changeset 18177 in vbox for trunk/src


Ignore:
Timestamp:
Mar 24, 2009 1:21:12 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
44892
Message:

Main: turn read/write param in OpenHardDisk into an enum

Location:
trunk/src/VBox
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r18164 r18177  
    12631263    {
    12641264        ComPtr<IHardDisk> hardDisk;
    1265         CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, TRUE /* fWrite */, hardDisk.asOutParam()));
     1265        CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, AccessMode_ReadWrite, hardDisk.asOutParam()));
    12661266    }
    12671267
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r18162 r18177  
    388388        if (!hardDisk)
    389389        {
    390             a->virtualBox->OpenHardDisk(Bstr(a->argv[0]), hardDisk.asOutParam());
     390            a->virtualBox->OpenHardDisk(Bstr(a->argv[0]), AccessMode_ReadWrite, hardDisk.asOutParam());
    391391            if (!hardDisk)
    392392                return errorArgument("Hard disk image not found");
     
    521521        if (FAILED (rc))
    522522        {
    523             CHECK_ERROR(a->virtualBox, OpenHardDisk(src, TRUE /* fWrite */, srcDisk.asOutParam()));
     523            CHECK_ERROR(a->virtualBox, OpenHardDisk(src, AccessMode_ReadWrite, srcDisk.asOutParam()));
    524524            if (SUCCEEDED (rc))
    525525            {
     
    943943        if (FAILED (rc))
    944944        {
    945             CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, TRUE /* fWrite */, hardDisk.asOutParam()));
     945            CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, AccessMode_ReadWrite, hardDisk.asOutParam()));
    946946            if (SUCCEEDED (rc))
    947947            {
     
    10831083
    10841084        ComPtr<IHardDisk> hardDisk;
    1085         CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, TRUE /* fWrite */, hardDisk.asOutParam()));
     1085        CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, AccessMode_ReadWrite, hardDisk.asOutParam()));
    10861086        if (SUCCEEDED(rc) && hardDisk)
    10871087        {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r18162 r18177  
    10541054                    {
    10551055                        /* open the new hard disk object */
    1056                         CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), TRUE /* fWrite */, hardDisk.asOutParam()));
     1056                        CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), AccessMode_ReadWrite, hardDisk.asOutParam()));
    10571057                    }
    10581058                }
     
    10871087                    {
    10881088                        /* open the new hard disk object */
    1089                         CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), TRUE /* fWrite */, hardDisk.asOutParam()));
     1089                        CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), AccessMode_ReadWrite, hardDisk.asOutParam()));
    10901090                    }
    10911091                }
     
    11201120                    {
    11211121                        /* open the new hard disk object */
    1122                         CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), TRUE /* fWrite */, hardDisk.asOutParam()));
     1122                        CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), AccessMode_ReadWrite, hardDisk.asOutParam()));
    11231123                    }
    11241124                }
     
    18331833                        {
    18341834                            /* open the new hard disk object */
    1835                             CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), TRUE /* fWrite */, hardDisk.asOutParam()));
     1835                            CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, hardDisk.asOutParam()));
    18361836                        }
    18371837                    }
     
    19221922                        {
    19231923                            /* open the new hard disk object */
    1924                             CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), TRUE /* fWrite */, hardDisk.asOutParam()));
     1924                            CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, hardDisk.asOutParam()));
    19251925                        }
    19261926                    }
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r18162 r18177  
    16701670            /* we've not found the image */
    16711671            RTPrintf("Adding hard disk '%S'...\n", hdaFile);
    1672             virtualBox->OpenHardDisk(hdaFileBstr, TRUE /* fWrite */, hardDisk.asOutParam());
     1672            virtualBox->OpenHardDisk(hdaFileBstr, AccessMode_ReadWrite, hardDisk.asOutParam());
    16731673        }
    16741674        /* do we have the right image now? */
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp

    r18162 r18177  
    15451545        case VBoxDefs::MediaType_HardDisk:
    15461546        {
    1547             CHardDisk hd = mVBox.OpenHardDisk(aLocation, TRUE /* fWrite */);
     1547            CHardDisk hd = mVBox.OpenHardDisk(aLocation, KAccessMode_ReadWrite);
    15481548            if (mVBox.isOk())
    15491549            {
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r18162 r18177  
    23122312                            /* First open the existing disk image */
    23132313                            rc = pVirtualBox->OpenHardDisk(Bstr(strSrcFilePath),
    2314                                                            FALSE,           // read-only
     2314                                                           AccessMode_ReadOnly,
    23152315                                                           srcHdVBox.asOutParam());
    23162316                            if (FAILED(rc)) throw rc;
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r18162 r18177  
    11331133}
    11341134
    1135 STDMETHODIMP VirtualBox::OpenHardDisk(IN_BSTR aLocation, BOOL fWrite, IHardDisk **aHardDisk)
     1135STDMETHODIMP VirtualBox::OpenHardDisk(IN_BSTR aLocation,
     1136                                      AccessMode_T accessMode,
     1137                                      IHardDisk **aHardDisk)
    11361138{
    11371139    CheckComArgNotNull(aLocation);
     
    11491151    rc = hardDisk->init(this,
    11501152                        aLocation,
    1151                         (fWrite) ? HardDisk::OpenReadWrite : HardDisk::OpenReadOnly );
     1153                        (accessMode == AccessMode_ReadWrite) ? HardDisk::OpenReadWrite : HardDisk::OpenReadOnly );
    11521154
    11531155    if (SUCCEEDED (rc))
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r18163 r18177  
    360360
    361361  <enum
     362       name="AccessMode"
     363       uuid="1da0007c-ddf7-4be8-bcac-d84a1558785f"
     364       >
     365      <desc>
     366          Access mode for opening files.
     367      </desc>
     368
     369      <const name="ReadOnly"   value="1"/>
     370      <const name="ReadWrite"  value="2"/>
     371  </enum>
     372
     373  <enum
    362374    name="MachineState"
    363375    uuid="73bf04d0-7c4f-4684-9abf-d65a9ad74343"
     
    18741886        by reading hard disk data at the specified location.
    18751887
    1876         If @a write is true, the image is opened for read/write access and must
    1877         have according permissions, as VirtualBox may actually write status
    1878         information into the disk's metadata sections. Note that write access
    1879         is required for all typical image usage in VirtualBox, since VirtualBox
    1880         may need to write metadata such as a UUID into the image. The only
    1881         exception is opening a source image temporarily for copying and
     1888        If @a write is ReadWrite (which it should be), the image is opened for
     1889        read/write access and must have according permissions, as VirtualBox
     1890        may actually write status information into the disk's metadata sections.
     1891
     1892        Note that write access is required for all typical image usage in VirtualBox,
     1893        since VirtualBox may need to write metadata such as a UUID into the image.
     1894        The only exception is opening a source image temporarily for copying and
    18821895        cloning when the image will quickly be closed again.
    18831896
     
    19031916        </desc>
    19041917      </param>
    1905       <param name="write" type="boolean" dir="in">
     1918      <param name="accessMode" type="AccessMode" dir="in">
    19061919          <desc>
    1907               If true, opens for read/write access. If false, opens for read access only.
     1920              Determines whether to open the image in read/write or read-only mode.
    19081921          </desc>
    19091922      </param>
  • trunk/src/VBox/Main/include/HardDiskImpl.h

    r18162 r18177  
    7878
    7979    enum HDDOpenMode  { OpenReadWrite, OpenReadOnly };
    80                 // have to use a special enum or otherwise the overloaded init() is ambiguous
     80                // have to use a special enum for the overloaded init() below;
     81                // can't use AccessMode_T from XIDL because that's mapped to an int
     82                // and would be ambiguous
    8183
    8284    // public initializer/uninitializer for internal purposes only
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r18162 r18177  
    151151    STDMETHOD(CreateHardDisk)(IN_BSTR aFormat, IN_BSTR aLocation,
    152152                               IHardDisk **aHardDisk);
    153     STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, BOOL fWrite, IHardDisk **aHardDisk);
     153    STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, AccessMode_T accessMode, IHardDisk **aHardDisk);
    154154    STDMETHOD(GetHardDisk) (IN_GUID aId, IHardDisk **aHardDisk);
    155155    STDMETHOD(FindHardDisk) (IN_BSTR aLocation, IHardDisk **aHardDisk);
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r17737 r18177  
    562562        Bstr src = L"E:\\develop\\innotek\\images\\NewHardDisk.vdi";
    563563        printf ("Opening the existing hard disk '%ls'...\n", src.raw());
    564         CHECK_ERROR_BREAK (virtualBox, OpenHardDisk (src, hd.asOutParam()));
     564        CHECK_ERROR_BREAK (virtualBox, OpenHardDisk (src, AccessMode_ReadWrite, hd.asOutParam()));
    565565        printf ("Enter to continue...\n");
    566566        getchar();
Note: See TracChangeset for help on using the changeset viewer.

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