check for "sfbk" in fluid_is_soundfont()

This commit is contained in:
derselbst 2018-01-06 21:57:07 +01:00
parent 9456bfab12
commit 292b7e028f

View file

@ -323,25 +323,32 @@ fluid_is_midifile(const char *filename)
* @param filename Path to the file to check
* @return TRUE if it could be a SoundFont, FALSE otherwise
*
* The current implementation only checks for the "RIFF" header in the file.
* It is useful only to distinguish between SoundFont and MIDI files.
* @note The current implementation only checks for the "RIFF" and "sfbk" headers in
* the file. It is useful to distinguish between SoundFont and other (e.g. MIDI) files.
*/
int
fluid_is_soundfont(const char *filename)
{
FILE* fp = fopen(filename, "rb");
char id[4];
char riff_id[4], sfbk_id[4];
if (fp == NULL) {
return 0;
}
if (fread((void*) id, 1, 4, fp) != 4) {
if((fread((void*) riff_id, 1, sizeof(riff_id), fp) != sizeof(riff_id)) ||
(fseek(fp, 4, SEEK_CUR) != 0) ||
(fread((void*) sfbk_id, 1, sizeof(sfbk_id), fp) != sizeof(sfbk_id)))
{
goto error_rec;
}
fclose(fp);
return (FLUID_STRNCMP(riff_id, "RIFF", sizeof(riff_id)) == 0) &&
(FLUID_STRNCMP(sfbk_id, "sfbk", sizeof(sfbk_id)) == 0);
error_rec:
fclose(fp);
return 0;
}
fclose(fp);
return FLUID_STRNCMP(id, "RIFF", 4) == 0;
}
/**