Changeset 27418 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Mar 16, 2010 5:30:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/xml.cpp
r26344 r27418 149 149 } 150 150 151 EIPRTFailure::EIPRTFailure(int aRC )151 EIPRTFailure::EIPRTFailure(int aRC, const char *pcszContext, ...) 152 152 : RuntimeError(NULL), 153 153 mRC(aRC) 154 154 { 155 char *newMsg = NULL; 156 RTStrAPrintf(&newMsg, "Runtime error: %d (%s)", aRC, RTErrGetShort(aRC)); 155 char *pszContext2; 156 va_list args; 157 va_start(args, pcszContext); 158 RTStrAPrintfV(&pszContext2, pcszContext, args); 159 char *newMsg; 160 RTStrAPrintf(&newMsg, "%s: %d (%s)", pszContext2, aRC, RTErrGetShort(aRC)); 157 161 setWhat(newMsg); 158 162 RTStrFree(newMsg); 163 RTStrFree(pszContext2); 159 164 } 160 165 … … 200 205 int vrc = RTFileOpen(&m->handle, aFileName, flags); 201 206 if (RT_FAILURE(vrc)) 202 throw EIPRTFailure(vrc );207 throw EIPRTFailure(vrc, "Runtime error opening '%s' for reading", aFileName); 203 208 204 209 m->opened = true; … … 234 239 { 235 240 uint64_t p = 0; 236 int vrc = RTFileSeek 237 if (RT_SUCCESS 241 int vrc = RTFileSeek(m->handle, 0, RTFILE_SEEK_CURRENT, &p); 242 if (RT_SUCCESS(vrc)) 238 243 return p; 239 244 240 throw EIPRTFailure (vrc);241 } 242 243 void File::setPos 245 throw EIPRTFailure(vrc, "Runtime error seeking in file '%s'", m->strFileName.c_str()); 246 } 247 248 void File::setPos(uint64_t aPos) 244 249 { 245 250 uint64_t p = 0; … … 250 255 if (((int64_t) aPos) < 0) 251 256 { 252 vrc = RTFileSeek 253 aPos -= (uint64_t) 257 vrc = RTFileSeek(m->handle, INT64_MAX, method, &p); 258 aPos -= (uint64_t)INT64_MAX; 254 259 method = RTFILE_SEEK_CURRENT; 255 260 } 256 261 /* seek the rest */ 257 if (RT_SUCCESS 258 vrc = RTFileSeek 259 if (RT_SUCCESS 262 if (RT_SUCCESS(vrc)) 263 vrc = RTFileSeek(m->handle, (int64_t) aPos, method, &p); 264 if (RT_SUCCESS(vrc)) 260 265 return; 261 266 262 throw EIPRTFailure (vrc);263 } 264 265 int File::read 267 throw EIPRTFailure(vrc, "Runtime error seeking in file '%s'", m->strFileName.c_str()); 268 } 269 270 int File::read(char *aBuf, int aLen) 266 271 { 267 272 size_t len = aLen; 268 int vrc = RTFileRead 269 if (RT_SUCCESS 273 int vrc = RTFileRead(m->handle, aBuf, len, &len); 274 if (RT_SUCCESS(vrc)) 270 275 return (int)len; 271 276 272 throw EIPRTFailure (vrc);273 } 274 275 int File::write 277 throw EIPRTFailure(vrc, "Runtime error reading from file '%s'", m->strFileName.c_str()); 278 } 279 280 int File::write(const char *aBuf, int aLen) 276 281 { 277 282 size_t len = aLen; … … 280 285 return (int)len; 281 286 282 throw EIPRTFailure (vrc);287 throw EIPRTFailure(vrc, "Runtime error writing to file '%s'", m->strFileName.c_str()); 283 288 284 289 return -1 /* failure */; … … 291 296 return; 292 297 293 throw EIPRTFailure (vrc);298 throw EIPRTFailure(vrc, "Runtime error truncating file '%s'", m->strFileName.c_str()); 294 299 } 295 300
Note:
See TracChangeset
for help on using the changeset viewer.