Merge pull request #264 from rickyviking/binaryStreamLargeBlock
BinaryStreamOperator: read and write block size as long long integer
This commit is contained in:
commit
eab845a4c5
@ -90,9 +90,9 @@ public:
|
|||||||
{
|
{
|
||||||
if ( mark._name=="{" )
|
if ( mark._name=="{" )
|
||||||
{
|
{
|
||||||
int size = 0;
|
long long size = 0;
|
||||||
_beginPositions.push_back( _out->tellp() );
|
_beginPositions.push_back( _out->tellp() );
|
||||||
_out->write( (char*)&size, osgDB::INT_SIZE );
|
_out->write( (char*)&size, osgDB::INT64_SIZE );
|
||||||
}
|
}
|
||||||
else if ( mark._name=="}" && _beginPositions.size()>0 )
|
else if ( mark._name=="}" && _beginPositions.size()>0 )
|
||||||
{
|
{
|
||||||
@ -101,8 +101,8 @@ public:
|
|||||||
_out->seekp( beginPos );
|
_out->seekp( beginPos );
|
||||||
|
|
||||||
std::streampos size64 = pos - beginPos;
|
std::streampos size64 = pos - beginPos;
|
||||||
int size = (int) size64;
|
long long size = (long long) size64;
|
||||||
_out->write( (char*)&size, osgDB::INT_SIZE );
|
_out->write( (char*)&size, osgDB::INT64_SIZE);
|
||||||
_out->seekp( pos );
|
_out->seekp( pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,13 +244,26 @@ public:
|
|||||||
{
|
{
|
||||||
if ( mark._name=="{" )
|
if ( mark._name=="{" )
|
||||||
{
|
{
|
||||||
int size = 0;
|
|
||||||
_beginPositions.push_back( _in->tellg() );
|
_beginPositions.push_back( _in->tellg() );
|
||||||
|
|
||||||
_in->read( (char*)&size, osgDB::INT_SIZE );
|
// since version 149 (osg version > 3.5.6) size is expressed
|
||||||
if ( _byteSwap ) osg::swapBytes( (char*)&size, osgDB::INT_SIZE );
|
// on 8 bytes rather than 4 bytes,
|
||||||
|
// to accommodate any block size.
|
||||||
|
if (getInputStream() && getInputStream()->getFileVersion() > 148)
|
||||||
|
{
|
||||||
|
long long size = 0;
|
||||||
|
_in->read( (char*)&size, osgDB::INT64_SIZE);
|
||||||
|
if ( _byteSwap ) osg::swapBytes( (char*)&size, osgDB::INT64_SIZE);
|
||||||
_blockSizes.push_back( size );
|
_blockSizes.push_back( size );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int size = 0;
|
||||||
|
_in->read( (char*)&size, osgDB::INT_SIZE);
|
||||||
|
if ( _byteSwap ) osg::swapBytes( (char*)&size, osgDB::INT_SIZE);
|
||||||
|
_blockSizes.push_back( size );
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ( mark._name=="}" && _beginPositions.size()>0 )
|
else if ( mark._name=="}" && _beginPositions.size()>0 )
|
||||||
{
|
{
|
||||||
_beginPositions.pop_back();
|
_beginPositions.pop_back();
|
||||||
@ -279,7 +292,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<std::streampos> _beginPositions;
|
std::vector<std::streampos> _beginPositions;
|
||||||
std::vector<int> _blockSizes;
|
std::vector<std::streampos> _blockSizes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user