Documentation ¶
Overview ¶
Package siegfried identifies file formats
Example:
s, err := siegfried.Load("pronom.sig") if err != nil { log.Fatal(err) } f, err := os.Open("file") if err != nil { log.Fatal(err) } defer f.Close() ids, err := s.Identify(f, "filename.ext", "application/xml") if err != nil { log.Fatal(err) } for _, id := range ids { fmt.Println(id) }
Index ¶
- type Siegfried
- func (s *Siegfried) Add(i core.Identifier) error
- func (s *Siegfried) Blame(idx, ct int, cn string) string
- func (s *Siegfried) Buffer(r io.Reader) (*siegreader.Buffer, error)
- func (s *Siegfried) Fields() [][]string
- func (s *Siegfried) Identifiers() [][2]string
- func (s *Siegfried) Identify(r io.Reader, name, mime string) ([]core.Identification, error)
- func (s *Siegfried) IdentifyBuffer(buffer *siegreader.Buffer, err error, name, mime string) ([]core.Identification, error)
- func (s *Siegfried) Inspect(t core.MatcherType) string
- func (s *Siegfried) Label(id core.Identification) [][2]string
- func (s *Siegfried) Put(buffer *siegreader.Buffer)
- func (s *Siegfried) Save(path string) error
- func (s *Siegfried) SaveWriter(w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Siegfried ¶
type Siegfried struct { // immutable fields C time.Time // signature create time // contains filtered or unexported fields }
Siegfried structs are persisent objects that can be serialised to disk and used to identify file formats. They contain three matchers as well as a slice of identifiers. When identifiers are added to a Siegfried struct, they are registered with each matcher.
func LoadReader ¶ added in v1.7.12
LoadReader creates a Siegfried struct and loads content from a reader
func New ¶
func New() *Siegfried
New creates a new Siegfried struct. It initializes the three matchers.
Example:
s := New() p, err := pronom.New() // create a new PRONOM identifier if err != nil { log.Fatal(err) } err = s.Add(p) // add the identifier to the Siegfried if err != nil { log.Fatal(err) } err = s.Save("pronom.sig") // save the Siegfried
func (*Siegfried) Add ¶
func (s *Siegfried) Add(i core.Identifier) error
Add adds an identifier to a Siegfried struct.
func (*Siegfried) Blame ¶
Blame checks with the byte matcher to see what identification results subscribe to a particular result or test tree index. It can be used when identifying in a debug mode to check which identification results trigger which strikes.
func (*Siegfried) Identifiers ¶ added in v1.7.1
Identifiers returns a slice of the names and details of each identifier.
func (*Siegfried) Identify ¶
Identify identifies a stream or file object. It takes an io.Reader and the name and mimetype of the file/stream (if unknown, give empty strings). It returns a slice of identifications and an error.
func (*Siegfried) IdentifyBuffer ¶ added in v1.7.1
func (s *Siegfried) IdentifyBuffer(buffer *siegreader.Buffer, err error, name, mime string) ([]core.Identification, error)
IdentifyBuffer identifies a siegreader buffer. Supply the error from Get as the second argument.
func (*Siegfried) Inspect ¶
func (s *Siegfried) Inspect(t core.MatcherType) string
Inspect returns a string containing detail about the various matchers in the Siegfried struct.
func (*Siegfried) Label ¶ added in v1.7.1
func (s *Siegfried) Label(id core.Identification) [][2]string
Label takes the values of a core.Identification and returns a slice that pairs these values with the relevant identifier's field labels.
func (*Siegfried) Put ¶ added in v1.7.1
func (s *Siegfried) Put(buffer *siegreader.Buffer)
Put returns a siegreader buffer to the pool
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
bytematcher
Package bytematcher builds a matching engine from a set of signatures and performs concurrent matching against an input siegreader.Buffer.
|
Package bytematcher builds a matching engine from a set of signatures and performs concurrent matching against an input siegreader.Buffer. |
bytematcher/frames
Package frames describes the Frame interface.
|
Package frames describes the Frame interface. |
bytematcher/frames/tests
Package tests exports shared frames and signatures for use by the other bytematcher packages
|
Package tests exports shared frames and signatures for use by the other bytematcher packages |
bytematcher/patterns
Package patterns describes the Pattern interface.
|
Package patterns describes the Pattern interface. |
bytematcher/patterns/tests
Package tests exports shared patterns for use by the other bytematcher packages
|
Package tests exports shared patterns for use by the other bytematcher packages |
persist
Package persist marshals and unmarshals siegfried signatures as binary data
|
Package persist marshals and unmarshals siegfried signatures as binary data |
priority
Package priority creates a subordinate-superiors map of identifications.
|
Package priority creates a subordinate-superiors map of identifications. |
siegreader
Package siegreader implements multiple independent Readers (and ReverseReaders) from a single Buffer.
|
Package siegreader implements multiple independent Readers (and ReverseReaders) from a single Buffer. |
pkg
|
|
config
Package config sets up defaults used by both the SF and roy tools Config options can be overridden with build flags e.g.
|
Package config sets up defaults used by both the SF and roy tools Config options can be overridden with build flags e.g. |
core
Package core defines a set of core interfaces: Identifier, Recorder, Identification, and Matcher
|
Package core defines a set of core interfaces: Identifier, Recorder, Identification, and Matcher |
decompress
Package decompress provides zip, tar, gzip and webarchive decompression/unpacking
|
Package decompress provides zip, tar, gzip and webarchive decompression/unpacking |
pronom
Define custom patterns (implementing the siegfried.Pattern interface) for the different patterns allowed by the PRONOM spec.
|
Define custom patterns (implementing the siegfried.Pattern interface) for the different patterns allowed by the PRONOM spec. |
pronom/internal/mappings
Package mappings contains struct mappings to unmarshal three different PRONOM XML formats: the DROID signature file format, the report format, and the container format.
|
Package mappings contains struct mappings to unmarshal three different PRONOM XML formats: the DROID signature file format, the report format, and the container format. |
static
Code generated by go generate; DO NOT EDIT.
|
Code generated by go generate; DO NOT EDIT. |
wikidata
Package wikidata contains the majority of the functions needed to build a Wikidata identifier (compiled signature file) compatible with Siegfried.
|
Package wikidata contains the majority of the functions needed to build a Wikidata identifier (compiled signature file) compatible with Siegfried. |
wikidata/internal/converter
Convert file-format signature sequences to something compatible with Siegfried's identifiers.
|
Convert file-format signature sequences to something compatible with Siegfried's identifiers. |
wikidata/internal/mappings
Package mappings provides data structures and helpers that describe Wikidata signature resources that we want to work with.
|
Package mappings provides data structures and helpers that describe Wikidata signature resources that we want to work with. |