changeset 369:5d0a74c31ee6 trunk

[svn] Use file magic instead of extensions.
author chainsaw
date Sat, 31 Dec 2005 15:04:34 -0800
parents fb59081b528f
children 11d9ea46c9c7
files Plugins/Input/musepack/libmpc.cpp Plugins/Input/musepack/libmpc.h
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/musepack/libmpc.cpp	Sat Dec 31 14:47:56 2005 -0800
+++ b/Plugins/Input/musepack/libmpc.cpp	Sat Dec 31 15:04:34 2005 -0800
@@ -202,11 +202,17 @@
 
 static int mpcIsOurFile(char* p_Filename)
 {
-    char* ext;
-    ext = strrchr(p_Filename, '.');
-    if(ext)
-        return !(strcasecmp(ext, ".mpc") && strcasecmp(ext, ".mpp") && strcasecmp(ext, ".mp+"));
-    return FALSE;
+   VFSFile *file;
+   gchar magic[3];
+   if (file = vfs_fopen(p_Filename, "rb")) {
+       vfs_fread(magic, 1, 3, file);
+       if (!strncmp(magic, "MP+", 3)) {
+            vfs_fclose(file);
+            return 1;
+       }
+       vfs_fclose(file);
+   }
+   return 0;
 }
 
 static void mpcPlay(char* p_Filename)
--- a/Plugins/Input/musepack/libmpc.h	Sat Dec 31 14:47:56 2005 -0800
+++ b/Plugins/Input/musepack/libmpc.h	Sat Dec 31 15:04:34 2005 -0800
@@ -9,6 +9,7 @@
 #include "libaudacious/util.h"
 #include "libaudacious/configdb.h"
 #include "libaudacious/titlestring.h"
+#include "libaudacious/vfs.h"
 }
 
 //stdlib headers