Changeset 3065 for box/trunk/lib
- Timestamp:
- 22/01/2012 16:28:01 (4 months ago)
- File:
-
- 1 edited
-
box/trunk/lib/common/FileStream.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/FileStream.cpp
r2808 r3065 191 191 else 192 192 { 193 BOX_LOG_WIN_ERROR("Failed to read from file: " << mFileName); 194 r = -1; 193 THROW_WIN_FILE_ERROR("Failed to read from file", mFileName, 194 CommonException, OSFileReadError); 195 } 196 197 if(r == -1) 198 { 199 THROW_EXCEPTION(CommonException, OSFileReadError) 195 200 } 196 201 #else … … 198 203 if(r == -1) 199 204 { 200 BOX_LOG_SYS_ERROR("Failed to read from file: " << mFileName); 201 } 202 #endif 203 204 if(r == -1) 205 { 206 THROW_EXCEPTION(CommonException, OSFileReadError) 207 } 205 THROW_SYS_FILE_ERROR("Failed to read from file", mFileName, 206 CommonException, OSFileReadError); 207 } 208 #endif 208 209 209 210 if(r == 0) … … 229 230 if(EMU_FSTAT(mOSFileHandle, &st) != 0) 230 231 { 231 THROW_EXCEPTION(CommonException, OSFileError)232 BOX_LOG_SYS_ERROR(BOX_FILE_MESSAGE("Failed to stat file", mFileName)); 232 233 } 233 234 … … 263 264 if ((res == 0) || (numBytesWritten != (DWORD)NBytes)) 264 265 { 265 // DWORD err = GetLastError();266 THROW_EXCEPTION(CommonException, OSFileWriteError)266 THROW_WIN_FILE_ERROR("Failed to write to file", mFileName, 267 CommonException, OSFileWriteError); 267 268 } 268 269 #else 269 270 if(::write(mOSFileHandle, pBuffer, NBytes) != NBytes) 270 271 { 271 BOX_LOG_SYS_ERROR("Failed to write to file: " << mFileName);272 THROW_EXCEPTION(CommonException, OSFileWriteError)272 THROW_SYS_FILE_ERROR("Failed to write to file", mFileName, 273 CommonException, OSFileWriteError); 273 274 } 274 275 #endif … … 293 294 #ifdef WIN32 294 295 LARGE_INTEGER conv; 295 296 296 conv.HighPart = 0; 297 conv.LowPart = 0;298 299 297 conv.LowPart = SetFilePointer(this->mOSFileHandle, 0, &conv.HighPart, FILE_CURRENT); 298 299 if(conv.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) 300 { 301 THROW_WIN_FILE_ERROR("Failed to seek in file", mFileName, 302 CommonException, OSFileError); 303 } 300 304 301 305 return (IOStream::pos_type)conv.QuadPart; … … 304 308 if(p == -1) 305 309 { 306 THROW_EXCEPTION(CommonException, OSFileError) 310 THROW_SYS_FILE_ERROR("Failed to seek in file", mFileName, 311 CommonException, OSFileError); 307 312 } 308 313 … … 329 334 #ifdef WIN32 330 335 LARGE_INTEGER conv; 331 332 336 conv.QuadPart = Offset; 333 337 DWORD retVal = SetFilePointer(this->mOSFileHandle, conv.LowPart, &conv.HighPart, ConvertSeekTypeToOSWhence(SeekType)); … … 335 339 if(retVal == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) 336 340 { 337 THROW_EXCEPTION(CommonException, OSFileError) 341 THROW_WIN_FILE_ERROR("Failed to seek in file", mFileName, 342 CommonException, OSFileError); 338 343 } 339 344 #else // ! WIN32 340 345 if(::lseek(mOSFileHandle, Offset, ConvertSeekTypeToOSWhence(SeekType)) == -1) 341 346 { 342 THROW_EXCEPTION(CommonException, OSFileError) 347 THROW_SYS_FILE_ERROR("Failed to seek in file", mFileName, 348 CommonException, OSFileError); 343 349 } 344 350 #endif // WIN32 … … 366 372 #ifdef WIN32 367 373 if(::CloseHandle(mOSFileHandle) == 0) 368 #else 374 { 375 THROW_WIN_FILE_ERROR("Failed to close file", mFileName, 376 CommonException, OSFileCloseError); 377 } 378 #else // ! WIN32 369 379 if(::close(mOSFileHandle) != 0) 370 #endif 371 { 372 THROW_EXCEPTION(CommonException, OSFileCloseError) 373 } 380 { 381 THROW_SYS_FILE_ERROR("Failed to close file", mFileName, 382 CommonException, OSFileCloseError); 383 } 384 #endif // WIN32 374 385 375 386 mOSFileHandle = INVALID_FILE;
Note: See TracChangeset
for help on using the changeset viewer.
