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=="{" )
|
||||
{
|
||||
int size = 0;
|
||||
long long size = 0;
|
||||
_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 )
|
||||
{
|
||||
@ -101,8 +101,8 @@ public:
|
||||
_out->seekp( beginPos );
|
||||
|
||||
std::streampos size64 = pos - beginPos;
|
||||
int size = (int) size64;
|
||||
_out->write( (char*)&size, osgDB::INT_SIZE );
|
||||
long long size = (long long) size64;
|
||||
_out->write( (char*)&size, osgDB::INT64_SIZE);
|
||||
_out->seekp( pos );
|
||||
}
|
||||
}
|
||||
@ -244,12 +244,25 @@ public:
|
||||
{
|
||||
if ( mark._name=="{" )
|
||||
{
|
||||
int size = 0;
|
||||
_beginPositions.push_back( _in->tellg() );
|
||||
|
||||
_in->read( (char*)&size, osgDB::INT_SIZE );
|
||||
if ( _byteSwap ) osg::swapBytes( (char*)&size, osgDB::INT_SIZE );
|
||||
_blockSizes.push_back( size );
|
||||
// since version 149 (osg version > 3.5.6) size is expressed
|
||||
// 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 );
|
||||
}
|
||||
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 )
|
||||
{
|
||||
@ -279,7 +292,7 @@ public:
|
||||
|
||||
protected:
|
||||
std::vector<std::streampos> _beginPositions;
|
||||
std::vector<int> _blockSizes;
|
||||
std::vector<std::streampos> _blockSizes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user