yumeko: bitbucket.org/abex/yumeko/mime Index | Files | Directories

package mime

import "bitbucket.org/abex/yumeko/mime"

package mime implements part of the shared-mime-info spec for guessing by extension and partial matching by header


Package Files

glob.go match.go read.go

type Database Uses

type Database struct {
    // contains filtered or unexported fields

Database holds the LUTs for glob matching and magic matching

func NewDatabase Uses

func NewDatabase() *Database

NewDatabase Creates a new empty database

func (*Database) GuessExtByMIME Uses

func (d *Database) GuessExtByMIME(mime string) string

GuessExtByMIME attempts to get a file extension (including the dot) by a mime type.

func (*Database) GuessMIMEByHeader Uses

func (d *Database) GuessMIMEByHeader(header []byte) string

GuessMIMEByHeader attemtps to deterimine the MIME type by the file's header. It returns "" on failure

func (*Database) GuessMIMEByName Uses

func (d *Database) GuessMIMEByName(name string) string

GuessMIMEByName guesses a mime type by filename. This is faster than guessing by magic, but very easy to fool returns a empty string on failure

func (*Database) ReadFreeDesktop Uses

func (db *Database) ReadFreeDesktop(database io.Reader) error

ReadFreeDesktop reads into a existing database from a XML document stream describing mime matching

func (*Database) RecommendedLength Uses

func (d *Database) RecommendedLength() int

RecommendedLength returns the length required by GuessMIMEByHeader for all matches


freedesktoppackage freedesktop provides the verbatim FreeDesktop shared-mime-lib decoders.
minimalpackage minimal provides a more minimal set of mime types tailored more to webservers where serving a video with the corrent MIME is more important than a word document

Package mime imports 7 packages (graph) and is imported by 5 packages. Updated 2019-09-24. Refresh now. Tools for package owners.