filetype

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Empty  = New("empty", types.Unknown, func(b []byte) bool { return len(b) == 0 }, 1000)
	Binary = New("binary", types.Unknown, func(b []byte) bool { return len(b) > 0 }, 1000)
	Text   = &Filetype{"text", types.NewMIME("text/plain"), []string{"txt"}, isASCII, 900}
)
View Source
var (
	MBR     = &Filetype{"mbr", types.NewMIME("filesystem/mbr"), []string{"dd"}, MBRMatch, 1}
	GPT     = &Filetype{"gpt", types.NewMIME("filesystem/gpt"), []string{"dd"}, GPTMatch, 0}
	FAT16   = &Filetype{"fat16", types.NewMIME("filesystem/fat16"), []string{"dd"}, FAT16Match, 0}
	HFSPlus = &Filetype{"hfsplus", types.NewMIME("filesystem/hfsplus"), []string{"dd"}, HFSPlusMatch, 0}
	ExFAT   = &Filetype{"exfat", types.NewMIME("filesystem/exfat"), []string{"dd"}, ExFATMatch, 0}
	NTFS    = &Filetype{"ntfs", types.NewMIME("filesystem/ntfs"), []string{"dd"}, NTFSMatch, 0}
)
View Source
var (
	Wasm = New("wasm", matchers.TypeWasm, matchers.Wasm, 0)

	Epub   = New("epub", matchers.TypeEpub, matchers.Epub, 0)
	Zip    = New("zip", matchers.TypeZip, matchers.Zip, 10)
	Tar    = New("tar", matchers.TypeTar, matchers.Tar, 0)
	Rar    = New("rar", matchers.TypeRar, matchers.Rar, 0)
	Gz     = New("gz", matchers.TypeGz, matchers.Gz, 0)
	Bz2    = New("bz2", matchers.TypeBz2, matchers.Bz2, 0)
	Sevenz = New("7z", matchers.Type7z, matchers.SevenZ, 0)
	Xz     = New("xz", matchers.TypeXz, matchers.Xz, 0)
	Pdf    = New("pdf", matchers.TypePdf, matchers.Pdf, 0)
	Exe    = New("exe", matchers.TypeExe, matchers.Exe, 0)
	Swf    = New("swf", matchers.TypeSwf, matchers.Swf, 0)
	Rtf    = New("rtf", matchers.TypeRtf, matchers.Rtf, 0)
	Eot    = New("eot", matchers.TypeEot, matchers.Eot, 0)
	Ps     = New("ps", matchers.TypePs, matchers.Ps, 0)
	Sqlite = New("sqlite", matchers.TypeSqlite, matchers.Sqlite, 0)
	Nes    = New("nes", matchers.TypeNes, matchers.Nes, 0)
	Crx    = New("crx", matchers.TypeCrx, matchers.Crx, 0)
	Cab    = New("cab", matchers.TypeCab, matchers.Cab, 0)
	Deb    = New("deb", matchers.TypeDeb, matchers.Deb, 0)
	Ar     = New("ar", matchers.TypeAr, matchers.Ar, 0)
	Z      = New("Z      =", matchers.TypeZ, matchers.Z, 0)
	Lz     = New("lz", matchers.TypeLz, matchers.Lz, 0)
	Rpm    = New("rpm", matchers.TypeRpm, matchers.Rpm, 0)
	Elf    = New("elf", matchers.TypeElf, matchers.Elf, 0)
	Dcm    = New("dcm", matchers.TypeDcm, matchers.Dcm, 0)
	Iso    = New("iso", matchers.TypeIso, matchers.Iso, 0)

	Midi = New("midi", matchers.TypeMidi, matchers.Midi, 0)
	Mp3  = New("mp3", matchers.TypeMp3, matchers.Mp3, 0)
	M4a  = New("m4a", matchers.TypeM4a, matchers.M4a, 0)
	Ogg  = New("ogg", matchers.TypeOgg, matchers.Ogg, 0)
	Flac = New("flac", matchers.TypeFlac, matchers.Flac, 0)
	Wav  = New("wav", matchers.TypeWav, matchers.Wav, 0)
	Amr  = New("amr", matchers.TypeAmr, matchers.Amr, 0)
	Aac  = New("aac", matchers.TypeAac, matchers.Aac, 0)

	Doc  = New("doc", matchers.TypeDoc, matchers.Doc, 0)
	Docx = New("docx", matchers.TypeDocx, matchers.Docx, 0)
	Xls  = New("xls", matchers.TypeXls, matchers.Xls, 0)
	Xlsx = New("xlsx", matchers.TypeXlsx, matchers.Xlsx, 0)
	Ppt  = New("ppt", matchers.TypePpt, matchers.Ppt, 0)
	Pptx = New("pptx", matchers.TypePptx, matchers.Pptx, 0)

	Woff  = New("woff", matchers.TypeWoff, matchers.Woff, 0)
	Woff2 = New("woff2", matchers.TypeWoff2, matchers.Woff2, 0)
	Ttf   = New("ttf", matchers.TypeTtf, matchers.Ttf, 0)
	Otf   = New("otf", matchers.TypeOtf, matchers.Otf, 0)

	Jpeg     = New("jpeg", matchers.TypeJpeg, matchers.Jpeg, 0)
	Jpeg2000 = New("jpeg2000", matchers.TypeJpeg2000, matchers.Jpeg2000, 0)
	Png      = New("png", matchers.TypePng, matchers.Png, 0)
	Gif      = New("gif", matchers.TypeGif, matchers.Gif, 0)
	Webp     = New("webp", matchers.TypeWebp, matchers.Webp, 0)
	CR2      = New("cr2", matchers.TypeCR2, matchers.CR2, 0)
	Tiff     = New("tiff", matchers.TypeTiff, matchers.Tiff, 0)
	Bmp      = New("bmp", matchers.TypeBmp, matchers.Bmp, 0)
	Jxr      = New("jxr", matchers.TypeJxr, matchers.Jxr, 0)
	Psd      = New("psd", matchers.TypePsd, matchers.Psd, 0)
	Ico      = New("ico", matchers.TypeIco, matchers.Ico, 0)
	Heif     = New("heif", matchers.TypeHeif, matchers.Heif, 0)
	Dwg      = New("dwg", matchers.TypeDwg, matchers.Dwg, 0)

	Mp4     = New("mp4", matchers.TypeMp4, matchers.Mp4, 0)
	M4v     = New("m4v", matchers.TypeM4v, matchers.M4v, 0)
	Mkv     = New("mkv", matchers.TypeMkv, matchers.Mkv, 0)
	Webm    = New("webm", matchers.TypeWebm, matchers.Webm, 0)
	Mov     = New("mov", matchers.TypeMov, matchers.Mov, 0)
	Avi     = New("avi", matchers.TypeAvi, matchers.Avi, 0)
	Wmv     = New("wmv", matchers.TypeWmv, matchers.Wmv, 0)
	Mpeg    = New("mpeg", matchers.TypeMpeg, matchers.Mpeg, 0)
	Flv     = New("flv", matchers.TypeFlv, matchers.Flv, 0)
	Threegp = New("3gp", matchers.Type3gp, matchers.Match3gp, 0)
)

Functions

func ExFATMatch

func ExFATMatch(buf []byte) bool

func FAT16Match

func FAT16Match(buf []byte) bool

func GPTMatch

func GPTMatch(buf []byte) bool

func HFSPlusMatch

func HFSPlusMatch(buf []byte) bool

func MBRMatch

func MBRMatch(buf []byte) bool

func NTFSMatch

func NTFSMatch(buf []byte) bool

Types

type Filetype

type Filetype struct {
	ID         ID
	Mimetype   MIME
	Extensions []string
	Matcher    func(buf []byte) bool
	// contains filtered or unexported fields
}

func Detect

func Detect(buf []byte) *Filetype

func DetectByExtension

func DetectByExtension(buf []byte, guess string) *Filetype

func DetectReader

func DetectReader(r io.Reader) (*Filetype, error)

func DetectReaderByExtension

func DetectReaderByExtension(r io.Reader, guess string) (*Filetype, error)

func New

func New(id ID, t types.Type, matcher func([]byte) bool, layer int) *Filetype

type ID

type ID string

type MIME

type MIME = types.MIME

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL