diff options
Diffstat (limited to 'libs/fluidsynth/src/fluid_midi.c')
-rw-r--r-- | libs/fluidsynth/src/fluid_midi.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libs/fluidsynth/src/fluid_midi.c b/libs/fluidsynth/src/fluid_midi.c index 8deb0b0d1b..73551a6d8c 100644 --- a/libs/fluidsynth/src/fluid_midi.c +++ b/libs/fluidsynth/src/fluid_midi.c @@ -34,6 +34,7 @@ static long fluid_getlength(unsigned char *s); * Note: This rewinds the file to the start before reading. * Returns NULL if there was an error reading or allocating memory. */ +typedef FILE *fluid_file; static char *fluid_file_read_full(fluid_file fp, size_t *length); static void fluid_midi_event_set_sysex_LOCAL(fluid_midi_event_t *evt, int type, void *data, int size, int dynamic); static void fluid_midi_event_get_sysex_LOCAL(fluid_midi_event_t *evt, void **data, int *size); @@ -92,17 +93,23 @@ static int fluid_midi_file_get_division(fluid_midi_file *midifile); */ int fluid_is_midifile(const char *filename) { - FILE *fp = FLUID_FOPEN(filename, "rb"); + FILE *fp; uint32_t id; int retcode = FALSE; do { - if(fp == NULL) + if(!fluid_file_test(filename, G_FILE_TEST_IS_REGULAR)) { return retcode; } - + + // file seems to exist and is a regular file or a symlink to such + if((fp = FLUID_FOPEN(filename, "rb")) == NULL) + { + return retcode; + } + if(FLUID_FREAD(&id, sizeof(id), 1, fp) != 1) { break; |