rendered paste bodystd::string GetTorrentName( std::string filename )
{
FILE *file = fopen( filename.c_str(), "rb" );
if( file == NULL )
{
return "";
}
fseek( file, 0, SEEK_END );
unsigned int size = ftell( file );
rewind( file );
char *content = new char[size];
fread( content, 1, size, file );
fclose( file );
std::string data( content, size );
delete content;
std::string::size_type offset = 1;
std::string::size_type sep = 0;
// BIT OF A HACK TO GET STRAIGHT TO THE FILENAME
// SINCE THERE IS NO POINT IN DECODING THE OTHER DATA
offset = data.find( ":name", offset ) + 5;
sep = data.find( ":", offset );
size = atoi( data.substr( offset, sep - offset ).c_str() );
offset = sep + 1;
return data.substr( offset, size );
}