VirtualBox

Changeset 38818 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 21, 2011 5:10:25 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74113
Message:

Main/Medium+Snapshot+VirtualBox: extend the API in a compatible way to support skipping the automatic directory creation when creating new images.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r38786 r38818  
    97839783      </desc>
    97849784    </const>
     9785    <const name="NoCreateDir" value="0x40000000">
     9786      <desc>
     9787        Special flag which suppresses automatic creation of the subdirectory.
     9788        Only used when passing the medium variant as an input parameter.
     9789      </desc>
     9790    </const>
    97859791  </enum>
    97869792
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r37985 r38818  
    282282    HRESULT saveRegistries(const GuidList &llRegistriesThatNeedSaving);
    283283
    284     static HRESULT ensureFilePathExists(const Utf8Str &strFileName);
     284    static HRESULT ensureFilePathExists(const Utf8Str &strFileName, bool fCreate);
    285285
    286286    static HRESULT handleUnexpectedExceptions (RT_SRC_POS_DECL);
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r38775 r38818  
    64486448            if (capabilities & MediumFormatCapabilities_File)
    64496449            {
    6450                 rc = VirtualBox::ensureFilePathExists(location);
     6450                rc = VirtualBox::ensureFilePathExists(location, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */);
    64516451                if (FAILED(rc))
    64526452                    throw rc;
     
    64596459                               location.c_str(),
    64606460                               task.mSize,
    6461                                task.mVariant,
     6461                               task.mVariant & ~MediumVariant_NoCreateDir,
    64626462                               NULL,
    64636463                               &geo,
     
    66156615            if (capabilities & MediumFormatCapabilities_File)
    66166616            {
    6617                 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation);
     6617                HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */);
    66186618                if (FAILED(rc))
    66196619                    throw rc;
     
    66236623                               targetFormat.c_str(),
    66246624                               targetLocation.c_str(),
    6625                                task.mVariant | VD_IMAGE_FLAGS_DIFF,
     6625                               (task.mVariant & ~MediumVariant_NoCreateDir) | VD_IMAGE_FLAGS_DIFF,
    66266626                               NULL,
    66276627                               targetId.raw(),
     
    71187118            if (capabilities & MediumFormatCapabilities_File)
    71197119            {
    7120                 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation);
     7120                HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */);
    71217121                if (FAILED(rc))
    71227122                    throw rc;
     
    71817181                                 false /* fMoveByRename */,
    71827182                                 0 /* cbSize */,
    7183                                  task.mVariant,
     7183                                 task.mVariant & ~MediumVariant_NoCreateDir,
    71847184                                 targetId.raw(),
    71857185                                 VD_OPEN_FLAGS_NORMAL,
     
    71997199                                   task.midxSrcImageSame,
    72007200                                   task.midxDstImageSame,
    7201                                    task.mVariant,
     7201                                   task.mVariant & ~MediumVariant_NoCreateDir,
    72027202                                   targetId.raw(),
    72037203                                   VD_OPEN_FLAGS_NORMAL,
     
    77897789            if (capabilities & MediumFormatCapabilities_File)
    77907790            {
    7791                 rc = VirtualBox::ensureFilePathExists(targetLocation);
     7791                rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */);
    77927792                if (FAILED(rc))
    77937793                    throw rc;
     
    78077807                             false /* fMoveByRename */,
    78087808                             0 /* cbSize */,
    7809                              task.mVariant,
     7809                             task.mVariant & ~MediumVariant_NoCreateDir,
    78107810                             NULL /* pDstUuid */,
    78117811                             VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_SEQUENTIAL,
     
    79147914            if (capabilities & MediumFormatCapabilities_File)
    79157915            {
    7916                 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation);
     7916                HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */);
    79177917                if (FAILED(rc))
    79187918                    throw rc;
     
    79757975                             false /* fMoveByRename */,
    79767976                             0 /* cbSize */,
    7977                              task.mVariant,
     7977                             task.mVariant & ~MediumVariant_NoCreateDir,
    79787978                             targetId.raw(),
    79797979                             VD_OPEN_FLAGS_NORMAL,
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r38718 r38818  
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    14311431    {
    14321432        // ensure the directory for the saved state file exists
    1433         HRESULT rc = VirtualBox::ensureFilePathExists(strStateFilePath);
     1433        HRESULT rc = VirtualBox::ensureFilePathExists(strStateFilePath, true /* fCreate */);
    14341434        if (FAILED(rc)) return rc;
    14351435    }
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r38754 r38818  
    39323932
    39333933/**
    3934  * Creates the path to the specified file according to the path information
    3935  * present in the file name.
     3934 * Checks if the path to the specified file exists, according to the path
     3935 * information present in the file name. Optionally the path is created.
    39363936 *
    39373937 * Note that the given file name must contain the full path otherwise the
     
    39393939 * directory which is normally unknown.
    39403940 *
    3941  * @param aFileName     Full file name which path needs to be created.
    3942  *
    3943  * @return Extended error information on failure to create the path.
     3941 * @param aFileName     Full file name which path is checked/created.
     3942 * @param aCreate       Flag if the path should be created if it doesn't exist.
     3943 *
     3944 * @return Extended error information on failure to check/create the path.
    39443945 */
    39453946/* static */
    3946 HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName)
     3947HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName, bool fCreate)
    39473948{
    39483949    Utf8Str strDir(strFileName);
     
    39503951    if (!RTDirExists(strDir.c_str()))
    39513952    {
    3952         int vrc = RTDirCreateFullPath(strDir.c_str(), 0777);
    3953         if (RT_FAILURE(vrc))
    3954             return setErrorStatic(E_FAIL,
    3955                                   Utf8StrFmt(tr("Could not create the directory '%s' (%Rrc)"),
    3956                                              strDir.c_str(),
    3957                                              vrc));
     3953        if (fCreate)
     3954        {
     3955            int vrc = RTDirCreateFullPath(strDir.c_str(), 0777);
     3956            if (RT_FAILURE(vrc))
     3957                return setErrorStatic(VBOX_E_IPRT_ERROR,
     3958                                      Utf8StrFmt(tr("Could not create the directory '%s' (%Rrc)"),
     3959                                                 strDir.c_str(),
     3960                                                 vrc));
     3961        }
     3962        else
     3963            return setErrorStatic(VBOX_E_IPRT_ERROR,
     3964                                  Utf8StrFmt(tr("Directory '%s' does not exist"),
     3965                                             strDir.c_str()));
    39583966    }
    39593967
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