コード例 #1
0
MemoryReader::MemoryReader( Memory &source )
:curPos( 0 )
{
  this->curData = source.GetData();
  this->curLength = source.GetLength();
  this->curPos = 0;
}//constructor
コード例 #2
0
bool FileManagerWin32::GetFile( const std::string& fileName, Memory& fileContent, bool endZeroByte ) const {
  std::string name = fileName;
  FILE *file;
  fileContent.Free();
  fopen_s( &file, name.c_str(), "rb" );
  if( !file ) {
    LOGE( "File '%s' not found", name.c_str() );
    return false;
  }
  fseek( file, 0, SEEK_END );
  size_t fileSize = ftell( file );
  if( fileSize ) {
    fseek( file, 0, SEEK_SET );
    fileContent.Alloc( fileSize + ( endZeroByte ? 1 : 0 ) );
    fread( fileContent.GetData(), fileSize, 1, file );
    fileContent[ fileContent.GetLength() - 1 ] = 0;
  }
  fclose( file );

  return true;
}//GetFile