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() c, err := s.Identify("filename", f) if err != nil { log.Fatal(err) } for id := range c { 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() *siegreader.Buffer
- func (s *Siegfried) Fields() [][]string
- func (s *Siegfried) Identify(r io.Reader, name, mime string) (chan core.Identification, error)
- func (s *Siegfried) Inspect(t core.MatcherType) string
- func (s *Siegfried) JSON() string
- func (s *Siegfried) Save(path string) error
- func (s *Siegfried) String() string
- func (s *Siegfried) Update(t string) bool
- func (s *Siegfried) YAML() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Siegfried ¶
type Siegfried struct { 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 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) Buffer ¶
func (s *Siegfried) Buffer() *siegreader.Buffer
Buffer returns the last buffer inspected This prevents unnecessary double-up of IO e.g. when unzipping files post-identification.
func (*Siegfried) Identify ¶
Identify identifies a stream or file object. It takes the name of the file/stream (if unknown, give an empty string) and an io.Reader It returns a channel of identifications and an error.
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) JSON ¶
JSON representation of a Siegfried struct. This is the provenace block at the beginning of sf results and includes descriptions for each identifier.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
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. |
pkg
|
|
core
Package core defines the Identifier, Identification, Recorder, Matcher and Result interfaces.
|
Package core defines the Identifier, Identification, Recorder, Matcher and Result interfaces. |
core/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. |
core/bytematcher/frames
Package frames describes the Frame interface.
|
Package frames describes the Frame interface. |
core/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 |
core/bytematcher/patterns
Package patterns describes the Pattern interface.
|
Package patterns describes the Pattern interface. |
core/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 |
core/persist
Package persist marshals and unmarshals siegfried signatures as binary data
|
Package persist marshals and unmarshals siegfried signatures as binary data |
core/priority
Package priority creates a subordinate-superiors map of identifications.
|
Package priority creates a subordinate-superiors map of identifications. |
core/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. |
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/mappings
This file contains struct mappings to unmarshal three different PRONOM XML formats: the signature file format, the report format, and the container format
|
This file contains struct mappings to unmarshal three different PRONOM XML formats: the signature file format, the report format, and the container format |