Changeset 17400 in vbox
- Timestamp:
- Mar 5, 2009 1:55:30 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r17362 r17400 2460 2460 writer.write(pAppliance->m->strPath.c_str()); 2461 2461 } 2462 catch(xml::Error &x) 2463 { 2464 rc = setError(VBOX_E_FILE_ERROR, 2465 x.what()); 2466 } 2462 2467 catch(HRESULT aRC) 2463 2468 { -
trunk/src/VBox/Main/xml/xml.cpp
r17362 r17400 967 967 } 968 968 969 struct ReadWriteContext969 struct IOContext 970 970 { 971 971 File file; 972 972 com::Utf8Str error; 973 973 974 ReadWriteContext(const char *pcszFilename)975 : file( File::Mode_Read, pcszFilename) // @todo must be write for writer974 IOContext(const char *pcszFilename, File::Mode mode) 975 : file(mode, pcszFilename) 976 976 { 977 977 } … … 985 985 { 986 986 error = x.what(); 987 } 988 }; 989 990 struct ReadContext : IOContext 991 { 992 ReadContext(const char *pcszFilename) 993 : IOContext(pcszFilename, File::Mode_Read) 994 { 995 } 996 }; 997 998 struct WriteContext : IOContext 999 { 1000 WriteContext(const char *pcszFilename) 1001 : IOContext(pcszFilename, File::Mode_Write) 1002 { 987 1003 } 988 1004 }; … … 1005 1021 m->strXmlFilename = pcszFilename; 1006 1022 1007 Read WriteContext context(pcszFilename);1023 ReadContext context(pcszFilename); 1008 1024 doc.m->reset(); 1009 1025 if (!(doc.m->plibDocument = xmlCtxtReadIO(m->ctxt, … … 1022 1038 int XmlFileParser::ReadCallback(void *aCtxt, char *aBuf, int aLen) 1023 1039 { 1024 Read WriteContext *pContext = static_cast<ReadWriteContext*>(aCtxt);1040 ReadContext *pContext = static_cast<ReadContext*>(aCtxt); 1025 1041 1026 1042 /* To prevent throwing exceptions while inside libxml2 code, we catch … … 1068 1084 } 1069 1085 1070 int XmlFileWriter::WriteCallback(void *aCtxt, const char *aBuf, int aLen)1071 {1072 ReadWriteContext *pContext = static_cast<ReadWriteContext*>(aCtxt);1073 1074 /* To prevent throwing exceptions while inside libxml2 code, we catch1075 * them and forward to our level using a couple of variables. */1076 try1077 {1078 return pContext->file.write(aBuf, aLen);1079 }1080 catch (const xml::EIPRTFailure &err) { pContext->setError(err); }1081 catch (const xml::Error &err) { pContext->setError(err); }1082 catch (const std::exception &err) { pContext->setError(err); }1083 catch (...) { pContext->setError(xml::LogicError(RT_SRC_POS)); }1084 1085 return -1 /* failure */;1086 }1087 1088 int XmlFileWriter::CloseCallback(void *aCtxt)1089 {1090 /// @todo to be written1091 1092 return -1;1093 }1094 1095 1086 void XmlFileWriter::write(const char *pcszFilename) 1096 1087 { 1097 ReadWriteContext context(pcszFilename);1088 WriteContext context(pcszFilename); 1098 1089 1099 1090 GlobalLock lock(); … … 1127 1118 } 1128 1119 1120 int XmlFileWriter::WriteCallback(void *aCtxt, const char *aBuf, int aLen) 1121 { 1122 WriteContext *pContext = static_cast<WriteContext*>(aCtxt); 1123 1124 /* To prevent throwing exceptions while inside libxml2 code, we catch 1125 * them and forward to our level using a couple of variables. */ 1126 try 1127 { 1128 return pContext->file.write(aBuf, aLen); 1129 } 1130 catch (const xml::EIPRTFailure &err) { pContext->setError(err); } 1131 catch (const xml::Error &err) { pContext->setError(err); } 1132 catch (const std::exception &err) { pContext->setError(err); } 1133 catch (...) { pContext->setError(xml::LogicError(RT_SRC_POS)); } 1134 1135 return -1 /* failure */; 1136 } 1137 1138 int XmlFileWriter::CloseCallback(void *aCtxt) 1139 { 1140 /// @todo to be written 1141 1142 return -1; 1143 } 1144 1129 1145 1130 1146 } // end namespace xml
Note:
See TracChangeset
for help on using the changeset viewer.