VirtualBox

Changeset 36187 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Mar 7, 2011 1:52:38 PM (14 years ago)
Author:
vboxsync
Message:

Main/Machine: handle the case where snapshot dir = VM dir (previously made VirtualBox switch to the default), and also rename the previous VM config files to reduce clutter.

File:
1 edited

Legend:

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

    r36181 r36187  
    60626062    strTarget.stripFilename();
    60636063    if (RTPathStartsWith(strSource.c_str(), strTarget.c_str()))
     6064    {
    60646065        // is relative: then append what's left
    60656066        strTarget = strSource.substr(strTarget.length() + 1); // skip '/'
     6067        // for empty paths (only possible for subdirs) use "." to avoid
     6068        // triggering default settings for not present config attributes.
     6069        if (strTarget.isEmpty())
     6070            strTarget = ".";
     6071    }
    60666072    else
    60676073        // is not relative: then overwrite
     
    80288034
    80298035        Utf8Str configFile, newConfigFile;
     8036        Utf8Str configFilePrev, newConfigFilePrev;
    80308037        Utf8Str configDir, newConfigDir;
    80318038
     
    80938100                    }
    80948101                    fileRenamed = true;
     8102                    configFilePrev = configFile;
     8103                    configFilePrev += "-prev";
     8104                    newConfigFilePrev = newConfigFile;
     8105                    newConfigFilePrev += "-prev";
     8106                    RTFileRename(configFilePrev.c_str(), newConfigFilePrev.c_str(), 0);
    80958107                }
    80968108            }
     
    81278139            /* silently try to rename everything back */
    81288140            if (fileRenamed)
     8141            {
     8142                RTFileRename(newConfigFilePrev.c_str(), configFilePrev.c_str(), 0);
    81298143                RTFileRename(newConfigFile.c_str(), configFile.c_str(), 0);
     8144            }
    81308145            if (dirRenamed)
    81318146                RTPathRename(newConfigDir.c_str(), configDir.c_str(), 0);
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