cvs diff: Diffing .
Index: mimedetect.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimedetect/mimedetect.install,v
retrieving revision 1.7.2.2
diff -u -p -r1.7.2.2 mimedetect.install
--- mimedetect.install	26 May 2010 20:43:11 -0000	1.7.2.2
+++ mimedetect.install	14 Jan 2011 23:26:58 -0000
@@ -28,7 +28,8 @@ function mimedetect_requirements($phase)
 
   if (extension_loaded('fileinfo')) {
     $requirement['value'] = $t('PHP Fileinfo Extension');
-    if (!$finfo = @finfo_open(FILEINFO_MIME, variable_get('mimedetect_magic', drupal_get_path('module', 'mimedetect') .'/magic'))) {
+    $magic_file = mimedetect_magic_file();
+    if (empty($magic_file)) {
       $requirement['description'] = $t('Fileinfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module.');
       $requirement['severity'] = REQUIREMENT_ERROR;
     }
@@ -54,3 +55,24 @@ function mimedetect_requirements($phase)
 
   return array('mimedetect' => $requirement);
 }
+
+
+/**
+ * Detect the proper mime file to use
+ */
+function mimedetect_magic_file() {
+  $file = variable_get('mimedetect_magic', '');
+  if (empty($file)) {
+    // drupal_get_path() is not safe for hook_requirements() in an install profile
+    $path = dirname(__FILE__) . '/';
+    $files = array('magic', 'magic.mime', 'magic.mgc');
+    foreach($files as $test) {
+      if ($finfo = @finfo_open(FILEINFO_MIME, $path . $test)) {
+        $file = $path . $test;
+        break;
+      }
+    }
+  }
+  return $file;
+}
+
Index: mimedetect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimedetect/mimedetect.module,v
retrieving revision 1.10.2.3
diff -u -p -r1.10.2.3 mimedetect.module
--- mimedetect.module	26 May 2010 20:41:15 -0000	1.10.2.3
+++ mimedetect.module	14 Jan 2011 23:26:58 -0000
@@ -53,7 +53,7 @@ function mimedetect_mime($file) {
   );
 
   $mime = FALSE;
-  $magic_file = variable_get('mimedetect_magic', drupal_get_path('module', 'mimedetect') .'/magic');
+  $magic_file = mimedetect_magic_file();
 
   // Try to use the fileinfo extension first.
   if (extension_loaded('fileinfo')) {
