changeset 544:3f45ec88fcd3 trunk

[svn] fix giacomo's bug I think
author nenolod
date Sat, 28 Jan 2006 13:45:34 -0800
parents 4eb4a52f440e
children 7d29b069b98a
files Plugins/Input/amidi-plug/amidi-plug.c
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/amidi-plug/amidi-plug.c	Sat Jan 28 11:49:45 2006 -0800
+++ b/Plugins/Input/amidi-plug/amidi-plug.c	Sat Jan 28 13:45:34 2006 -0800
@@ -31,15 +31,19 @@
 static gint amidiplug_is_our_file( gchar * filename )
 {
 #ifdef MIDIFILE_PROBE_MAGICBYTES
-    FILE * fp;
+    VFSFile * fp;
     gchar magic_bytes[4];
 
-    fp = fopen( filename , "rb" );
-    fread( magic_bytes , 1 , 4 , fp );
+    fp = vfs_fopen( filename , "rb" );
+
+    if (fp == NULL)
+	return FALSE;
+
+    vfs_fread( magic_bytes , 1 , 4 , fp );
 
     if ( !strncmp( magic_bytes , "MThd" , 4 ) )
     {
-      fclose( fp );
+      vfs_fclose( fp );
       DEBUGMSG( "MIDI found, %s is a standard midi file\n" , filename );
       return TRUE;
     }
@@ -48,16 +52,16 @@
     {
       /* skip the four bytes after RIFF,
          then read the next four */
-      fseek( fp , 4 , SEEK_CUR );
-      fread( magic_bytes , 1 , 4 , fp );
+      vfs_fseek( fp , 4 , SEEK_CUR );
+      vfs_fread( magic_bytes , 1 , 4 , fp );
       if ( !strncmp( magic_bytes , "RMID" , 4 ) )
       {
-        fclose( fp );
+        vfs_fclose( fp );
         DEBUGMSG( "MIDI found, %s is a riff midi file\n" , filename );
         return TRUE;
       }
     }
-    fclose( fp );
+    vfs_fclose( fp );
 #else
     gchar * ext = strrchr( filename, '.' );
     /* check the filename extension */