/**
  * @return \Components\Io_Charset
  */
 public function charset()
 {
     if (null === $this->m_charset) {
         $this->m_charset = Io_Charset::forName(self::$m_charsets[$this->m_name]);
     }
     return $this->m_charset;
 }
 /**
  * @param string $file_
  *
  * @return \Components\Io_Mimetype
  */
 public static function forFilePath($file_, Io_Charset $charset_ = null)
 {
     $info = null;
     if ($finfo = @finfo_open(FILEINFO_MIME)) {
         $info = @finfo_file($finfo, $file_);
         @finfo_close($finfo);
     }
     if (false === $info) {
         return self::forFileName($file_);
     }
     $mimetype = trim(substr($info, 0, strpos($info, ';')));
     /**
      * finfo seems to return text/plain for most text files..
      * I think we can achive more accurate information by relying on the
      * file extension, since there should be no real danger as soon as we
      * are sure its really a text file.
      */
     if (0 === strpos($mimetype, 'text')) {
         return static::forFileName($file_);
     }
     if (isset(self::$m_mapMimetypes[$mimetype])) {
         $name = self::$m_mapMimetypes[$mimetype];
     } else {
         $name = self::$m_mapMimetypes[self::APPLICATION_OCTET_STREAM];
     }
     if (null === $charset_) {
         $charset = trim(substr($info, strpos($info, ';') + 1));
         return static::$name(Io_Charset::forName($charset));
     }
     return static::$name($charset_);
 }