Changeset 35128 in vbox
- Timestamp:
- Dec 15, 2010 12:38:41 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/string.h
r34846 r35128 552 552 553 553 /** 554 * Converts all '\' characters into '/'.555 */556 Utf8Str& useForwardSlashes();557 558 /**559 554 * Static immutable empty-string object. May be used for comparison purposes. 560 555 */ -
trunk/include/iprt/cpp/ministring.h
r34785 r35128 664 664 665 665 /** 666 * Replaces all occurences of cFind with cReplace in the member string. 667 * In order not to produce invalid UTF-8, the characters must be ASCII 668 * values less than 128; this is not verified. 669 * 670 * @param cFind Character to replace. Must be ASCII < 128. 671 * @param cReplace Character to replace cFind with. Must be ASCII < 128. 672 */ 673 void findReplace(char cFind, char cReplace); 674 675 /** 666 676 * Returns a substring of "this" as a new Utf8Str. 667 677 * -
trunk/include/iprt/cpp/xml.h
r33835 r35128 454 454 bool getAttributeValue(const char *pcszMatch, const char *&ppcsz) const; 455 455 bool getAttributeValue(const char *pcszMatch, iprt::MiniString &str) const; 456 bool getAttributeValuePath(const char *pcszMatch, iprt::MiniString &str) const; 456 457 bool getAttributeValue(const char *pcszMatch, int32_t &i) const; 457 458 bool getAttributeValue(const char *pcszMatch, uint32_t &i) const; … … 473 474 return setAttribute(pcszName, strValue.c_str()); 474 475 } 476 AttributeNode* setAttributePath(const char *pcszName, const iprt::MiniString &strValue); 475 477 AttributeNode* setAttribute(const char *pcszName, int32_t i); 476 478 AttributeNode* setAttribute(const char *pcszName, uint32_t i); -
trunk/src/VBox/Main/glue/string.cpp
r34846 r35128 133 133 } 134 134 135 Utf8Str& Utf8Str::useForwardSlashes()136 {137 for (size_t i = 0; i < length(); ++i)138 {139 char *p = &m_psz[i];140 if (*p == '\\')141 *p = '/';142 }143 144 return *this;145 }146 147 135 /** 148 136 * Internal function used in Utf8Str copy constructors and assignment when -
trunk/src/VBox/Main/xml/Settings.cpp
r35123 r35128 647 647 if (fNeedsFilePath) 648 648 { 649 if (!(pelmImage->getAttributeValue ("filePath", med.strLocation)))649 if (!(pelmImage->getAttributeValuePath("filePath", med.strLocation))) 650 650 throw ConfigFileError(this, &elmMedium, N_("Required %s/@filePath attribute is missing"), elmMedium.getName()); 651 else652 // IPRT can handle forward slashes in file paths everywhere, but there might be653 // backslashes in the settings file, so convert them into forward slashes.654 med.strLocation.useForwardSlashes();655 651 } 656 652 } … … 1011 1007 pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly()); 1012 1008 1013 // always use forward slashes when writing out settings, never '\' 1014 Utf8Str strLocation(mdm.strLocation); 1015 strLocation.useForwardSlashes(); 1016 pelmMedium->setAttribute("location", strLocation); 1009 pelmMedium->setAttributePath("location", mdm.strLocation); 1017 1010 1018 1011 pelmMedium->setAttribute("format", mdm.strFormat); … … 3061 3054 parseTimestamp(snap.timestamp, strTemp); 3062 3055 3063 elmSnapshot.getAttributeValue ("stateFile", snap.strStateFile); // online snapshots only3056 elmSnapshot.getAttributeValuePath("stateFile", snap.strStateFile); // online snapshots only 3064 3057 3065 3058 // parse Hardware before the other elements because other things depend on it … … 3184 3177 convertOldOSType_pre1_5(machineUserData.strOsType); 3185 3178 3186 elmMachine.getAttributeValue("stateFile", strStateFile); 3179 elmMachine.getAttributeValuePath("stateFile", strStateFile); 3180 3187 3181 if (elmMachine.getAttributeValue("currentSnapshot", str)) 3188 3182 parseUUID(uuidCurrentSnapshot, str); 3189 3183 3190 elmMachine.getAttributeValue("snapshotFolder", machineUserData.strSnapshotFolder); 3191 // IPRT can handle forward slashes in file paths everywhere, but there might be 3192 // backslashes in the settings file, so convert them into forward slashes. 3193 machineUserData.strSnapshotFolder.useForwardSlashes(); 3184 elmMachine.getAttributeValuePath("snapshotFolder", machineUserData.strSnapshotFolder); 3194 3185 3195 3186 if (!elmMachine.getAttributeValue("currentStateModified", fCurrentStateModified)) … … 4122 4113 4123 4114 if (snap.strStateFile.length()) 4124 pelmSnapshot->setAttribute ("stateFile", snap.strStateFile);4115 pelmSnapshot->setAttributePath("stateFile", snap.strStateFile); 4125 4116 4126 4117 if (snap.strDescription.length()) … … 4210 4201 && !(fl & BuildMachineXML_SuppressSavedState) 4211 4202 ) 4212 elmMachine.setAttribute ("stateFile", strStateFile);4203 elmMachine.setAttributePath("stateFile", strStateFile); 4213 4204 if ( (fl & BuildMachineXML_IncludeSnapshots) 4214 4205 && !uuidCurrentSnapshot.isEmpty()) … … 4216 4207 4217 4208 if (machineUserData.strSnapshotFolder.length()) 4218 { 4219 // always use forward slashes when writing out settings, never '\' 4220 Utf8Str strSnapshotFolder(machineUserData.strSnapshotFolder); 4221 strSnapshotFolder.useForwardSlashes(); 4222 elmMachine.setAttribute("snapshotFolder", strSnapshotFolder); 4223 } 4209 elmMachine.setAttributePath("snapshotFolder", machineUserData.strSnapshotFolder); 4224 4210 if (!fCurrentStateModified) 4225 4211 elmMachine.setAttribute("currentStateModified", fCurrentStateModified); -
trunk/src/VBox/Runtime/common/string/ministring.cpp
r33605 r35128 212 212 213 213 return npos; 214 } 215 216 void MiniString::findReplace(char cFind, char cReplace) 217 { 218 for (size_t i = 0; i < length(); ++i) 219 { 220 char *p = &m_psz[i]; 221 if (*p == cFind) 222 *p = cReplace; 223 } 214 224 } 215 225 -
trunk/src/VBox/Runtime/r3/xml.cpp
r33835 r35128 831 831 { 832 832 str = pAttr->getValue(); 833 return true; 834 } 835 836 return false; 837 } 838 839 /** 840 * Like getAttributeValue (ministring variant), but makes sure that all backslashes 841 * are converted to forward slashes. 842 * @param pcszMatch 843 * @param str 844 * @return 845 */ 846 bool ElementNode::getAttributeValuePath(const char *pcszMatch, iprt::MiniString &str) const 847 { 848 if (getAttributeValue(pcszMatch, str)) 849 { 850 str.findReplace('\\', '/'); 833 851 return true; 834 852 } … … 1054 1072 1055 1073 /** 1074 * Like setAttribute (ministring variant), but replaces all backslashes with forward slashes 1075 * before calling that one. 1076 * @param pcszName 1077 * @param strValue 1078 * @return 1079 */ 1080 AttributeNode* ElementNode::setAttributePath(const char *pcszName, const iprt::MiniString &strValue) 1081 { 1082 iprt::MiniString strTemp(strValue); 1083 strTemp.findReplace('\\', '/'); 1084 return setAttribute(pcszName, strTemp.c_str()); 1085 } 1086 1087 /** 1056 1088 * Sets the given attribute; overloaded version for int32_t. 1057 1089 *
Note:
See TracChangeset
for help on using the changeset viewer.