function drush_mime_content_type

8.0.x drush.inc drush_mime_content_type($filename)
6.x drush.inc drush_mime_content_type($filename)
7.x drush.inc drush_mime_content_type($filename)
5.x drush.inc drush_mime_content_type($filename)
master drush.inc drush_mime_content_type($filename)

Determines the MIME content type of the specified file.

The power of this function depends on whether the PHP installation has either mime_content_type() or finfo installed -- if not, only tar, gz, zip and bzip2 types can be detected.

If mime type can't be obtained, an error will be set.

Return value

mixed The MIME content type of the file or FALSE.

File

includes/drush.inc, line 874
The drush API implementation and helpers.

Code

function drush_mime_content_type($filename) {
  $content_type = drush_attempt_mime_content_type($filename);
  if ($content_type) {
    drush_log(dt('Mime type for !file is !mt', array('!file' => $filename, '!mt' => $content_type)), LogLevel::NOTICE);
    return $content_type;
  }
  return drush_set_error('MIME_CONTENT_TYPE_UNKNOWN', dt('Unable to determine mime type for !file.', array('!file' => $filename)));
}