filetype: github.com/h2non/filetype Index | Files | Directories

package filetype

import "github.com/h2non/filetype"

Index

Package Files

filetype.go kind.go match.go version.go

Constants

const Version = "1.0.10"

Version exposes the current package version.

Variables

var ErrEmptyBuffer = errors.New("Empty buffer")

ErrEmptyBuffer represents an empty buffer error

var ErrUnknownBuffer = errors.New("Unknown buffer type")

ErrUnknownBuffer represents a unknown buffer error

var MatcherKeys = &matchers.MatcherKeys

MatcherKeys is an alias to matchers.MatcherKeys

var Matchers = matchers.Matchers

Matchers is an alias to matchers.Matchers

var NewMatcher = matchers.NewMatcher

NewMatcher is an alias to matchers.NewMatcher

var NewType = types.NewType

NewType creates and registers a new type

var Types = types.Types

Types stores a map of supported types

var Unknown = types.Unknown

Unknown represents an unknown file type

func AddMatcher Uses

func AddMatcher(fileType types.Type, matcher matchers.Matcher) matchers.TypeMatcher

AddMatcher registers a new matcher type

func AddType Uses

func AddType(ext, mime string) types.Type

AddType registers a new file type

func Archive Uses

func Archive(buf []byte) (types.Type, error)

Archive tries to match a file as generic archive type

func Audio Uses

func Audio(buf []byte) (types.Type, error)

Audio tries to match a file as audio type

func Document Uses

func Document(buf []byte) (types.Type, error)

Document tries to match a file as document type

func Font Uses

func Font(buf []byte) (types.Type, error)

Font tries to match a file as text font type

func Get Uses

func Get(buf []byte) (types.Type, error)

Get is an alias to Match()

func GetType Uses

func GetType(ext string) types.Type

GetType retrieves a Type by file extension

func Image Uses

func Image(buf []byte) (types.Type, error)

Image tries to match a file as image type

func Is Uses

func Is(buf []byte, ext string) bool

Is checks if a given buffer matches with the given file type extension

func IsArchive Uses

func IsArchive(buf []byte) bool

IsArchive checks if the given buffer is an archive type

func IsAudio Uses

func IsAudio(buf []byte) bool

IsAudio checks if the given buffer is an audio type

func IsDocument Uses

func IsDocument(buf []byte) bool

IsDocument checks if the given buffer is an document type

func IsExtension Uses

func IsExtension(buf []byte, ext string) bool

IsExtension semantic alias to Is()

func IsFont Uses

func IsFont(buf []byte) bool

IsFont checks if the given buffer is a font type

func IsImage Uses

func IsImage(buf []byte) bool

IsImage checks if the given buffer is an image type

func IsMIME Uses

func IsMIME(buf []byte, mime string) bool

IsMIME checks if a given buffer matches with the given MIME type

func IsMIMESupported Uses

func IsMIMESupported(mime string) bool

IsMIMESupported checks if a given MIME type is supported

func IsSupported Uses

func IsSupported(ext string) bool

IsSupported checks if a given file extension is supported

func IsType Uses

func IsType(buf []byte, kind types.Type) bool

IsType checks if a given buffer matches with the given file type

func IsVideo Uses

func IsVideo(buf []byte) bool

IsVideo checks if the given buffer is a video type

func Match Uses

func Match(buf []byte) (types.Type, error)

Match infers the file type of a given buffer inspecting its magic numbers signature

func MatchFile Uses

func MatchFile(filepath string) (types.Type, error)

MatchFile infers a file type for a file

func MatchMap Uses

func MatchMap(buf []byte, matchers matchers.Map) types.Type

MatchMap performs a file matching against a map of match functions

func MatchReader Uses

func MatchReader(reader io.Reader) (types.Type, error)

MatchReader is convenient wrapper to Match() any Reader

func Matches Uses

func Matches(buf []byte) bool

Matches checks if the given buffer matches with some supported file type

func MatchesMap Uses

func MatchesMap(buf []byte, matchers matchers.Map) bool

MatchesMap is an alias to Matches() but using matching against a map of match functions

func Video Uses

func Video(buf []byte) (types.Type, error)

Video tries to match a file as video type

Directories

PathSynopsis
matchers
matchers/isobmff
types

Package filetype imports 5 packages (graph) and is imported by 43 packages. Updated 2019-09-26. Refresh now. Tools for package owners.