本文整理汇总了C++中TMemoryStream::LoadFromBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ TMemoryStream::LoadFromBuffer方法的具体用法?C++ TMemoryStream::LoadFromBuffer怎么用?C++ TMemoryStream::LoadFromBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMemoryStream
的用法示例。
在下文中一共展示了TMemoryStream::LoadFromBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractItem
bool extractItem( FILEINDEX_ENTRY &info, unsigned char method, char *strMrf, char *strName )
{
TFileStream mrf( strMrf );
if( !( mrf.isOpen() ) )
{
printf("ERROR: Could not open file (%s)\n", strMrf );
return false;
}
// Format the output filename
std::string fname( fsRename( strMrf, strName ) );
#ifdef VERBOSE
printf("Using filename: %s\n", fname.c_str());
#endif
// UNFORCED EXTRACTION
// If file already exists, ignore it
if( TFileSize( fname.c_str() ) == info.size )
{
mrf.Close();
return true;
}
unsigned char *buf( new unsigned char[ info.zsize ] );
#ifdef VERBOSE
printf("Allocated %u bytes\n", info.zsize);
#endif
// Load MRF data into buffer
mrf.Seek( info.offset, bufo_start );
mrf.Read( buf, info.zsize );
mrf.Close();
#ifdef VERBOSE
printf("Read %u bytes at %u\n", info.zsize, info.offset );
#endif
// Copy into TStream
TMemoryStream fdata;
fdata.LoadFromBuffer( buf, info.zsize );
delete buf;
printf
(
( user_opt_allow_extraction ? "Saving %s.. " : "Checking %s.. " ),
fname.substr( fname.rfind('/') +1 ).c_str()
);
// Create path only when extraction is flagged
if( user_opt_allow_extraction )
fsCreatePath( fname );
switch( method )
{
// Compressed, most files
case FILEINDEX_ENTRY_COMPRESSED :
{
fsXor( info, fdata );
#ifdef VERBOSE
printf("Complete XOR routine\n");
#endif
TMemoryStream fdata_raw;
if( fsRle( fdata, fdata_raw ) )
{
#ifdef VERBOSE
printf("Completed RLE routine\n");
#endif
if( user_opt_allow_extraction )
fdata_raw.SaveToFile( fname.c_str() );
printf("done!\n");
}
// fsRle will display any errors
fdata_raw.Close();
break;
}
// Encrypted and compressed, some system data (GunZ 2)
case FILEINDEX_ENTRY_COMPRESSED2 :
{
TMemoryStream fdata_dec;
z3Decrypt( z3CurrentKey, fdata, fdata_dec );
fdata.Close();
// Now same as FILEINDEX_ENTRY_COMPRESSED
fsXor( info, fdata_dec );
TMemoryStream fdata_raw;
if( fsRle( fdata_dec, fdata_raw ) )
{
if( user_opt_allow_extraction )
fdata_raw.SaveToFile( fname.c_str() );
//.........这里部分代码省略.........
示例2: mrf
bool z3ResEx::extractItem( FILEINDEX_ENTRY &info, unsigned char method, const char *strMrf, const char *strName )
{
TFileStream mrf( strMrf );
if( !( mrf.isOpen() ) )
{
setMessage( "ERROR: Unable to open file (%s)", strMrf );
return false;
}
// Format the output filename
std::string fname( fsRename( strMrf, strName ) );
// UNFORCED EXTRACTION
// If file already exists, ignore it
if( TFileSize( fname.c_str() ) == info.size )
{
mrf.Close();
return true;
}
vector<unsigned char> buf( info.zsize );
// Load MRF data into buffer
mrf.Seek( info.offset, bufo_start );
mrf.Read( &buf[0], info.zsize );
mrf.Close();
// Copy into TStream
TMemoryStream fdata;
fdata.LoadFromBuffer( &buf[0], info.zsize );
buf.clear();
printf
(
( m_doExtraction ? "Saving %s.. " : "Checking %s.. " ),
fname.substr( fname.rfind('/') +1 ).c_str()
);
// Create path only when extraction is flagged
if( m_doExtraction )
fsCreatePath( fname );
switch( method )
{
// Compressed, most files
case FILEINDEX_ENTRY_COMPRESSED :
{
fsXor( fdata, info.xorkey );
TMemoryStream fdata_raw;
if( fsRle( fdata, fdata_raw ) )
{
if( m_doExtraction )
fdata_raw.SaveToFile( fname.c_str() );
puts(" ..done!");
}
// fsRle will display any errors
fdata_raw.Close();
break;
}
// Encrypted and compressed, some system data (GunZ 2)
case FILEINDEX_ENTRY_COMPRESSED2 :
{
TMemoryStream fdata_dec;
z3Decrypt( fdata, fdata_dec, m_fileindexKey, m_fileindexKeyLength );
fdata.Close();
// Now same as FILEINDEX_ENTRY_COMPRESSED
fsXor( fdata_dec, info.xorkey );
TMemoryStream fdata_raw;
if( fsRle( fdata_dec, fdata_raw ) )
{
if( m_doExtraction )
fdata_raw.SaveToFile( fname.c_str() );
printf(" ..done!\n");
}
// fsRle will display any errors
fdata_dec.Close();
fdata_raw.Close();
break;
}
// Large files, some FSB (GunZ 2)
case FILEINDEX_ENTRY_UNCOMPRESSED :
{
if( m_doExtraction )
fdata.SaveToFile( fname.c_str() );
puts(" ..done!");
//.........这里部分代码省略.........
示例3: mrf
bool z3ResEx::extractItem2( FILEINDEX_ENTRY2 &info, const string &strMrf, char *strName )
{
TFileStream mrf( strMrf.c_str() );
if( !( mrf.isOpen() ) )
{
setMessage( "ERROR: Unable to open file (%s)", strMrf.c_str() );
return false;
}
// Format the output filename
std::string fname( fsRename( strMrf.c_str(), strName ) );
// UNFORCED EXTRACTION
// If file already exists, ignore it
if( TFileSize( fname.c_str() ) == info.size )
{
mrf.Close();
return true;
}
unsigned char *buf( new unsigned char[ info.zsize ] );
// Load MRF data into buffer
mrf.Seek( info.offset, bufo_start );
mrf.Read( buf, info.zsize );
mrf.Close();
// Copy into TStream
TMemoryStream fdata;
fdata.LoadFromBuffer( buf, info.zsize );
delete buf;
printf( "Saving %s.. ", fname.substr( fname.rfind('/') +1 ).c_str() );
fsCreatePath( fname );
switch( info.type )
{
case FILEINDEXITEM_COMPRESSED :
{
fsXor( fdata, info.xorkey );
TMemoryStream fdata_raw;
if( fsRle( fdata, fdata_raw ) )
{
if( m_doExtraction )
fdata_raw.SaveToFile( fname.c_str() );
puts(" ..done!");
}
// fsRle will display any errors
fdata_raw.Close();
break;
}
/*
// Encrypted and compressed, some system data (GunZ 2)
case FILEINDEX_ENTRY_COMPRESSED2 :
{
TMemoryStream fdata_dec;
z3Decrypt( fdata, fdata_dec, m_fileindexKey, m_fileindexKeyLength );
fdata.Close();
// Now same as FILEINDEX_ENTRY_COMPRESSED
fsXor( info, fdata_dec );
TMemoryStream fdata_raw;
if( fsRle( fdata_dec, fdata_raw ) )
{
if( m_doExtraction )
fdata_raw.SaveToFile( fname.c_str() );
printf(" ..done!\n");
}
// fsRle will display any errors
fdata_dec.Close();
fdata_raw.Close();
break;
}
*/
case FILEINDEXITEM_UNCOMPRESSED :
{
fdata.SaveToFile( fname.c_str() );
puts(" ..done!");
break;
}
default:
{
fdata.Close();
//.........这里部分代码省略.........