| 1339 | |
| 1340 | |
| 1341 | void RemoteVstPlugin::loadPresetFile( const std::string & _file ) |
| 1342 | { |
| 1343 | void * chunk = NULL; |
| 1344 | unsigned int * pLen = new unsigned int[ 1 ]; |
| 1345 | unsigned int len = 0; |
| 1346 | sBank * pBank = (sBank*) new char[ sizeof( sBank ) ]; |
| 1347 | FILE * stream = F_OPEN_UTF8( _file, "rb" ); |
| 1348 | if (!stream) |
| 1349 | { |
| 1350 | fprintf( stderr, |
| 1351 | "Error opening file for loading preset.\n" ); |
| 1352 | return; |
| 1353 | } |
| 1354 | if ( fread ( pBank, 1, 56, stream ) != 56 ) |
| 1355 | { |
| 1356 | fprintf( stderr, "Error loading preset file.\n" ); |
| 1357 | } |
| 1358 | pBank->fxID = endian_swap( pBank->fxID ); |
| 1359 | pBank->numPrograms = endian_swap( pBank->numPrograms ); |
| 1360 | unsigned int toUInt; |
| 1361 | float * pFloat; |
| 1362 | |
| 1363 | if (m_plugin->uniqueID != pBank->fxID) { |
| 1364 | sendMessage( message( IdVstCurrentProgramName ). |
| 1365 | addString( "Error: Plugin UniqID not match" ) ); |
| 1366 | fclose( stream ); |
| 1367 | delete[] (unsigned int*)pLen; |
| 1368 | delete[] (sBank*)pBank; |
| 1369 | return; |
| 1370 | } |
| 1371 | |
| 1372 | if( _file.substr( _file.find_last_of( "." ) + 1 ) != "fxp" ) |
| 1373 | fseek ( stream , 156 , SEEK_SET ); |
| 1374 | |
| 1375 | if(pBank->fxMagic != 0x6B427846) { |
| 1376 | if(pBank->fxMagic != 0x6B437846) { |
| 1377 | if ( fread (pLen, 1, 4, stream) != 4 ) |
| 1378 | { |
| 1379 | fprintf( stderr, |
| 1380 | "Error loading preset file.\n" ); |
| 1381 | } |
| 1382 | chunk = new char[len = endian_swap(*pLen)]; |
| 1383 | } else chunk = new char[len = sizeof(float)*pBank->numPrograms]; |
| 1384 | if ( fread (chunk, len, 1, stream) != 1 ) |
| 1385 | { |
| 1386 | fprintf( stderr, "Error loading preset file.\n" ); |
| 1387 | } |
| 1388 | fclose( stream ); |
| 1389 | } |
| 1390 | |
| 1391 | if(_file.substr(_file.find_last_of(".") + 1) == "fxp") { |
| 1392 | pBank->prgName[23] = 0; |
| 1393 | pluginDispatch( 4, 0, 0, pBank->prgName ); |
| 1394 | if(pBank->fxMagic != 0x6B437846) |
| 1395 | pluginDispatch( 24, 1, len, chunk ); |
| 1396 | else |
| 1397 | { |
| 1398 | unsigned int* toUIntArray = reinterpret_cast<unsigned int*>( chunk ); |
nothing calls this directly
no test coverage detected