Changeset 33524 in vbox for trunk/src/VBox/Main/xml
- Timestamp:
- Oct 27, 2010 4:44:37 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67121
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r33504 r33524 671 671 else if (strType == "SHAREABLE") 672 672 med.hdType = MediumType_Shareable; 673 else if (strType == "READONLY") 674 med.hdType = MediumType_Readonly; 673 675 else 674 676 throw ConfigFileError(this, &elmMedium, N_("HardDisk/@type attribute must be one of Normal, Immutable or Writethrough")); 675 677 } 676 678 } 677 else if (m->sv < SettingsVersion_v1_4) 678 { 679 // DVD and floppy images before 1.4 had "src" attribute instead of "location" 680 if (!(elmMedium.getAttributeValue("src", med.strLocation))) 681 throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName()); 682 683 fNeedsLocation = false; 679 else 680 { 681 if (m->sv < SettingsVersion_v1_4) 682 { 683 // DVD and floppy images before 1.4 had "src" attribute instead of "location" 684 if (!(elmMedium.getAttributeValue("src", med.strLocation))) 685 throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName()); 686 687 fNeedsLocation = false; 688 } 689 690 if (!(elmMedium.getAttributeValue("format", med.strFormat))) 691 { 692 // DVD and floppy images before 1.11 had no format attribute. assign the default. 693 med.strFormat = "RAW"; 694 } 684 695 } 685 696 … … 979 990 * @param level 980 991 */ 981 void ConfigFileBase::buildHardDisk(xml::ElementNode &elmMedium, 982 const Medium &mdm, 983 uint32_t level) // 0 for "root" call, incremented with each recursion 984 { 985 xml::ElementNode *pelmHardDisk = elmMedium.createChild("HardDisk"); 986 pelmHardDisk->setAttribute("uuid", mdm.uuid.toStringCurly()); 987 pelmHardDisk->setAttribute("location", mdm.strLocation); 988 pelmHardDisk->setAttribute("format", mdm.strFormat); 992 void ConfigFileBase::buildMedium(xml::ElementNode &elmMedium, 993 DeviceType_T devType, 994 const Medium &mdm, 995 uint32_t level) // 0 for "root" call, incremented with each recursion 996 { 997 xml::ElementNode *pelmMedium; 998 999 if (devType == DeviceType_HardDisk) 1000 pelmMedium = elmMedium.createChild("HardDisk"); 1001 else 1002 pelmMedium = elmMedium.createChild("Image"); 1003 1004 pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly()); 1005 pelmMedium->setAttribute("location", mdm.strLocation); 1006 pelmMedium->setAttribute("format", mdm.strFormat); 989 1007 if (mdm.fAutoReset) 990 pelm HardDisk->setAttribute("autoReset", mdm.fAutoReset);1008 pelmMedium->setAttribute("autoReset", mdm.fAutoReset); 991 1009 if (mdm.strDescription.length()) 992 pelm HardDisk->setAttribute("Description", mdm.strDescription);1010 pelmMedium->setAttribute("Description", mdm.strDescription); 993 1011 994 1012 for (StringsMap::const_iterator it = mdm.properties.begin(); … … 996 1014 ++it) 997 1015 { 998 xml::ElementNode *pelmProp = pelm HardDisk->createChild("Property");1016 xml::ElementNode *pelmProp = pelmMedium->createChild("Property"); 999 1017 pelmProp->setAttribute("name", it->first); 1000 1018 pelmProp->setAttribute("value", it->second); … … 1008 1026 mdm.hdType == MediumType_Immutable ? "Immutable" : 1009 1027 mdm.hdType == MediumType_Writethrough ? "Writethrough" : 1010 mdm.hdType == MediumType_Shareable ? "Shareable" : "INVALID"; 1011 pelmHardDisk->setAttribute("type", pcszType); 1028 mdm.hdType == MediumType_Shareable ? "Shareable" : 1029 mdm.hdType == MediumType_Readonly ? "Readonly" : "INVALID"; 1030 pelmMedium->setAttribute("type", pcszType); 1012 1031 } 1013 1032 … … 1017 1036 { 1018 1037 // recurse for children 1019 buildHardDisk(*pelmHardDisk, // parent 1020 *it, // settings::Medium 1021 ++level); // recursion level 1038 buildMedium(*pelmMedium, // parent 1039 devType, // device type 1040 *it, // settings::Medium 1041 ++level); // recursion level 1022 1042 } 1023 1043 } … … 1044 1064 ++it) 1045 1065 { 1046 build HardDisk(*pelmHardDisks, *it, 0);1066 buildMedium(*pelmHardDisks, DeviceType_HardDisk, *it, 0); 1047 1067 } 1048 1068 … … 1052 1072 ++it) 1053 1073 { 1054 const Medium &mdm = *it; 1055 xml::ElementNode *pelmMedium = pelmDVDImages->createChild("Image"); 1056 pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly()); 1057 pelmMedium->setAttribute("location", mdm.strLocation); 1058 if (mdm.strDescription.length()) 1059 pelmMedium->setAttribute("Description", mdm.strDescription); 1074 buildMedium(*pelmDVDImages, DeviceType_DVD, *it, 0); 1060 1075 } 1061 1076 … … 1065 1080 ++it) 1066 1081 { 1067 const Medium &mdm = *it; 1068 xml::ElementNode *pelmMedium = pelmFloppyImages->createChild("Image"); 1069 pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly()); 1070 pelmMedium->setAttribute("location", mdm.strLocation); 1071 if (mdm.strDescription.length()) 1072 pelmMedium->setAttribute("Description", mdm.strDescription); 1082 buildMedium(*pelmFloppyImages, DeviceType_Floppy, *it, 0); 1073 1083 } 1074 1084 }
Note:
See TracChangeset
for help on using the changeset viewer.