1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0028736: An error to read a binary OCAF document of > 2Gb

A binary file of OCAF document contains file-position of several sections (header section, shape section).
This file-position represents an integer value.
For document files of less than 2Gb it is enough to use "int" type to keep the file-position.
But for greater document files we need more digits.
The fix consists in extension of the type for keeping of file-position within the document file on disk: it was "int", now it is "uint64_t".
This commit is contained in:
vro
2017-05-16 10:48:29 +03:00
committed by abv
parent a71a71de09
commit 41fbbba8c4
5 changed files with 65 additions and 37 deletions

View File

@@ -1860,20 +1860,20 @@ Standard_ShortReal FSD_BinaryFile::InverseShortReal (const Standard_ShortReal th
//=======================================================================
template<int size>
inline Standard_Size OCCT_InverseSizeSpecialized (const Standard_Size theValue, int);
inline uint64_t OCCT_InverseSizeSpecialized (const uint64_t theValue, int);
template<>
inline Standard_Size OCCT_InverseSizeSpecialized <4> (const Standard_Size theValue, int)
inline uint64_t OCCT_InverseSizeSpecialized <4> (const uint64_t theValue, int)
{
return FSD_BinaryFile::InverseInt(static_cast<Standard_Integer>(theValue));
}
template<>
inline Standard_Size OCCT_InverseSizeSpecialized <8> (const Standard_Size theValue, int)
inline uint64_t OCCT_InverseSizeSpecialized <8> (const uint64_t theValue, int)
{
union {
Standard_Integer i[2];
Standard_Size aValue;
uint64_t aValue;
} aWrapUnion;
aWrapUnion.aValue = theValue;
@@ -1887,5 +1887,10 @@ inline Standard_Size OCCT_InverseSizeSpecialized <8> (const Standard_Size theVal
Standard_Size FSD_BinaryFile::InverseSize (const Standard_Size theValue)
{
return OCCT_InverseSizeSpecialized <sizeof(Standard_Size)> (theValue, 0);
return (Standard_Size) OCCT_InverseSizeSpecialized <sizeof(Standard_Size)> (theValue, 0);
}
uint64_t FSD_BinaryFile::InverseUint64 (const uint64_t theValue)
{
return OCCT_InverseSizeSpecialized <sizeof(uint64_t)> (theValue, 0);
}

View File

@@ -335,6 +335,8 @@ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
///Inverse bytes in size value
Standard_EXPORT static Standard_Size InverseSize(const Standard_Size theValue);
///Inverse bytes in 64bit unsigned int value
Standard_EXPORT static uint64_t InverseUint64(const uint64_t theValue);
Standard_EXPORT static void ReadHeader (Standard_IStream& theIStream, FSD_FileHeader& theFileHeader);