Mercurial > audlegacy
changeset 368:fb59081b528f trunk
[svn] Use file magic instead of extensions.
author | chainsaw |
---|---|
date | Sat, 31 Dec 2005 14:47:56 -0800 |
parents | f0cbbb4071a4 |
children | 5d0a74c31ee6 |
files | Plugins/Input/flac/plugin.c |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Input/flac/plugin.c Sat Dec 31 14:37:03 2005 -0800 +++ b/Plugins/Input/flac/plugin.c Sat Dec 31 14:47:56 2005 -0800 @@ -28,6 +28,7 @@ #include <libaudacious/util.h> #include <libaudacious/configdb.h> #include <libaudacious/titlestring.h> +#include <libaudacious/vfs.h> #ifdef HAVE_CONFIG_H #include <config.h> @@ -288,12 +289,16 @@ int FLAC_XMMS__is_our_file(char *filename) { - char *ext; - - ext = strrchr(filename, '.'); - if(ext) - if(!strcasecmp(ext, ".flac") || !strcasecmp(ext, ".fla")) + VFSFile *file; + gchar magic[4]; + if (file = vfs_fopen(filename, "rb")) { + vfs_fread(magic, 1, 4, file); + if (!strncmp(magic, "fLaC", 4)) { + vfs_fclose(file); return 1; + } + vfs_fclose(file); + } return 0; }