Mercurial > audlegacy
changeset 367:f0cbbb4071a4 trunk
[svn] Use file magic instead of extensions.
author | chainsaw |
---|---|
date | Sat, 31 Dec 2005 14:37:03 -0800 |
parents | 4a9139a7b53e |
children | fb59081b528f |
files | Plugins/Input/timidity/src/xmms-timidity.c |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Input/timidity/src/xmms-timidity.c Sat Dec 31 14:17:51 2005 -0800 +++ b/Plugins/Input/timidity/src/xmms-timidity.c Sat Dec 31 14:37:03 2005 -0800 @@ -24,6 +24,7 @@ #include "libaudacious/util.h" #include "libaudacious/configdb.h" #include "libaudacious/titlestring.h" +#include "libaudacious/vfs.h" #include <gtk/gtk.h> #include <string.h> #include <timidity.h> @@ -230,13 +231,16 @@ } int xmmstimid_is_our_file(char *filename) { - gchar *ext; - - ext = strrchr(filename, '.'); - if (ext && !( - strcasecmp(ext, ".mid") && - strcasecmp(ext, ".midi"))) return 1; - + VFSFile *file; + gchar magic[4]; + if (file = vfs_fopen(filename, "rb")) { + vfs_fread(magic, 1, 4, file); + if (!strncmp(magic, "MThd", 4)) { + vfs_fclose(file); + return 1; + } + vfs_fclose(file); + } return 0; }