Changeset 11168
- Timestamp:
- 04/02/07 13:09:19 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.4/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp
r11101 r11168 34 34 * Added missing NULL pointer checks in SetPenFromStyleString(), 35 35 * SetBrushFromStyleString() and SetSymbolFromStyleString() (bug 1670) 36 * 37 * Revision 1.68 2007/02/22 18:35:53 dmorissette 38 * Fixed problem writing collections where MITAB was sometimes trying to 39 * read past EOF in write mode (bug 1657). 36 40 * 37 41 * Revision 1.66 2006/10/17 14:34:31 dmorissette … … 6753 6757 6754 6758 // And finally move the pointer back to the end of this component 6755 if (poCoordBlock->GotoByteInFile(nEndOfObjectPtr, TRUE ) != 0)6759 if (poCoordBlock->GotoByteInFile(nEndOfObjectPtr, TRUE, TRUE) != 0) 6756 6760 { 6757 6761 delete poRegionHdr; … … 6837 6841 6838 6842 // And finally move the pointer back to the end of this component 6839 if (poCoordBlock->GotoByteInFile(nEndOfObjectPtr, TRUE ) != 0)6843 if (poCoordBlock->GotoByteInFile(nEndOfObjectPtr, TRUE, TRUE) != 0) 6840 6844 { 6841 6845 delete poPlineHdr; … … 6920 6924 6921 6925 // And finally move the pointer back to the end of this component 6922 if (poCoordBlock->GotoByteInFile(nEndOfObjectPtr, TRUE ) != 0)6926 if (poCoordBlock->GotoByteInFile(nEndOfObjectPtr, TRUE, TRUE) != 0) 6923 6927 { 6924 6928 delete poMpointHdr; branches/1.4/gdal/ogr/ogrsf_frmts/mitab/mitab_priv.h
r8593 r11168 31 31 * 32 32 * $Log: mitab_priv.h,v $ 33 * Revision 1.44 2007/02/22 18:35:53 dmorissette 34 * Fixed problem writing collections where MITAB was sometimes trying to 35 * read past EOF in write mode (bug 1657). 36 * 33 37 * Revision 1.40 2005/10/06 19:15:31 dmorissette 34 38 * Collections: added support for reading/writing pen/brush/symbol ids and … … 758 762 int GotoByteRel(int nOffset); 759 763 int GotoByteInBlock(int nOffset); 760 int GotoByteInFile(int nOffset, GBool bForceReadFromFile=FALSE); 764 int GotoByteInFile(int nOffset, 765 GBool bForceReadFromFile = FALSE, 766 GBool bOffsetIsEndOfData = FALSE); 761 767 void SetFirstBlockPtr(int nOffset); 762 768 branches/1.4/gdal/ogr/ogrsf_frmts/mitab/mitab_rawbinblock.cpp
r8593 r11168 32 32 * 33 33 * $Log: mitab_rawbinblock.cpp,v $ 34 * Revision 1.10 2007/02/22 18:35:53 dmorissette 35 * Fixed problem writing collections where MITAB was sometimes trying to 36 * read past EOF in write mode (bug 1657). 37 * 34 38 * Revision 1.8 2005/10/06 19:15:31 dmorissette 35 39 * Collections: added support for reading/writing pen/brush/symbol ids and … … 434 438 * or other cases that need to do random access in the file in write mode.) 435 439 * 440 * bOffsetIsEndOfData is set to TRUE to indicate that the nOffset 441 * to which we are attempting to go is the end of the used data in this 442 * block (we are positioninig ourselves to append data), so if the nOffset 443 * corresponds to the beginning of a 512 bytes block then we should really 444 * be positioning ourselves at the end of the block that ends at this 445 * address instead of at the beginning of the blocks that starts at this 446 * address. This case can happen when going back and forth to write collection 447 * objects to a Coordblock and is documented in bug 1657. 448 * 436 449 * Returns 0 if succesful or -1 if an error happened, in which case 437 450 * CPLError() will have been called. 438 451 **********************************************************************/ 439 452 int TABRawBinBlock::GotoByteInFile(int nOffset, 440 GBool bForceReadFromFile /*=FALSE*/) 453 GBool bForceReadFromFile /*=FALSE*/, 454 GBool bOffsetIsEndOfData /*=FALSE*/) 441 455 { 442 456 int nNewBlockPtr; … … 480 494 // CommitToFile() should only be called only if something changed. 481 495 // 482 if ( (nOffset<m_nFileOffset || nOffset>=m_nFileOffset+m_nBlockSize) && 483 (CommitToFile() != 0 || 484 (!bForceReadFromFile && 485 InitNewBlock(m_fp, m_nBlockSize, nNewBlockPtr) != 0) || 486 (bForceReadFromFile && 487 ReadFromFile(m_fp, nNewBlockPtr, m_nBlockSize) != 0) ) ) 496 if (bOffsetIsEndOfData && nOffset%m_nBlockSize == 0) 488 497 { 489 // Failed reading new block... error has already been reported. 490 return -1; 498 /* We're trying to go byte 512 of a block that's full of data. 499 * In this case it's okay to place the m_nCurPos at byte 512 500 * which is past the end of the block. 501 */ 502 if ( (nOffset < m_nFileOffset || 503 nOffset > m_nFileOffset+m_nBlockSize) && 504 (CommitToFile() != 0 || 505 (!bForceReadFromFile && 506 InitNewBlock(m_fp, m_nBlockSize, nNewBlockPtr) != 0) || 507 (bForceReadFromFile && 508 ReadFromFile(m_fp, nNewBlockPtr, m_nBlockSize) != 0) ) ) 509 { 510 // Failed reading new block... error has already been reported. 511 return -1; 512 } 513 } 514 else 515 { 516 if ( (nOffset < m_nFileOffset || 517 nOffset >= m_nFileOffset+m_nBlockSize) && 518 (CommitToFile() != 0 || 519 (!bForceReadFromFile && 520 InitNewBlock(m_fp, m_nBlockSize, nNewBlockPtr) != 0) || 521 (bForceReadFromFile && 522 ReadFromFile(m_fp, nNewBlockPtr, m_nBlockSize) != 0) ) ) 523 { 524 // Failed reading new block... error has already been reported. 525 return -1; 526 } 491 527 } 492 528 }
