Old/mp3_InfoManager/field_binary.cpp
/** Copies binary data from the file specified to the field.
 **
 ** \code
 **   myFrame.GetField(ID3FN_DATA)->FromFile("mypic.jpg");
 ** \endcode
 **/
Copies binary data from the file specified to the field.
Copies binary data from the file specified to the field .
void ID3_FieldImpl::FromFile(const char *info 
                             )
{
  if (this->GetType() != ID3FTY_BINARY || NULL == info)
  {
    return;
  }
  FILE* temp_file = ::fopen(info, "rb");
  if (temp_file != NULL)
  {
    ::fseek(temp_file, 0, SEEK_END);
    size_t fileSize = ::ftell(temp_file);
    ::fseek(temp_file, 0, SEEK_SET);
    uchar* buffer = new uchar[fileSize];
    if (buffer != NULL)
    {
      ::fread(buffer, 1, fileSize, temp_file);
      this->Set(buffer, fileSize);
      delete [] buffer;
    }
    ::fclose(temp_file);
  }
}
void ID3_FieldImpl :: FromFile ( const char * info ) { if ( this -> GetType ( ) != ID3FTY_BINARY || NULL == info ) { return ; } FILE * temp_file = :: fopen ( info , " " ) ; if ( temp_file != NULL ) { :: fseek ( temp_file , 0 , SEEK_END ) ; size_t fileSize = :: ftell ( temp_file ) ; :: fseek ( temp_file , 0 , SEEK_SET ) ; uchar * buffer = new uchar [ fileSize ] ; if ( buffer != NULL ) { :: fread ( buffer , 1 , fileSize , temp_file ) ; this -> Set ( buffer , fileSize ) ; delete [ ] buffer ; } :: fclose ( temp_file ) ; } }
Copies binary data from the file specified to the field.
Copies binary data from the file specified to the field .
//< Source filename