Mercurial > audlegacy
changeset 366:4a9139a7b53e trunk
[svn] Use file magic instead of extensions (Phase 2).
author | chainsaw |
---|---|
date | Sat, 31 Dec 2005 14:17:51 -0800 |
parents | 98831d210c57 |
children | f0cbbb4071a4 |
files | Plugins/Input/console/Audacious_Driver.cpp |
diffstat | 1 files changed, 26 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Input/console/Audacious_Driver.cpp Sat Dec 31 13:36:01 2005 -0800 +++ b/Plugins/Input/console/Audacious_Driver.cpp Sat Dec 31 14:17:51 2005 -0800 @@ -16,6 +16,7 @@ #include "libaudacious/configdb.h" #include "libaudacious/util.h" #include "libaudacious/titlestring.h" +#include "libaudacious/vfs.h" #include "audacious/input.h" #include "audacious/output.h" #include "libaudcore/playback.h" @@ -57,24 +58,36 @@ static int is_our_file(gchar *filename) { - gchar *ext; - - ext = strrchr(filename, '.'); - - if (ext) - { - if (!strcasecmp(ext, ".spc")) + VFSFile *file; + gchar magic[4]; + if (file = vfs_fopen(filename, "rb")) { + vfs_fread(magic, 1, 4, file); + if (!strncmp(magic, "SNES", 4)) { + vfs_fclose(file); return PLAY_TYPE_SPC; - if (!strcasecmp(ext, ".nsf")) + } + if (!strncmp(magic, "NESM", 4)) { + vfs_fclose(file); return PLAY_TYPE_NSF; - if (!strcasecmp(ext, ".gbs")) + } + if (!strncmp(magic, "GYMX", 4)) { + vfs_fclose(file); + return PLAY_TYPE_GYM; + } + vfs_fclose(file); + } + if (file = vfs_fopen(filename, "rb")) { + vfs_fread(magic, 1, 3, file); + if (!strncmp(magic, "GBS", 3)) { + vfs_fclose(file); return PLAY_TYPE_GBS; - if (!strcasecmp(ext, ".gym")) - return PLAY_TYPE_GYM; - if (!strcasecmp(ext, ".vgm")) + } + if (!strncmp(magic, "Vgm", 3)) { + vfs_fclose(file); return PLAY_TYPE_VGM; + } + vfs_fclose(file); } - return 0; }