package conan

  1. Overview
  2. Docs
On This Page
  1. recognition.
Identify type of your file (such as the MIME type)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

conan-0.0.8.tbz
sha256=478c6ddac4fb3c3f43e9f7c71be1aa309d18f09b47e097fc9b3e5dcd047537c5
sha512=3658ab6cfc673fab0bb03915289d552b8147f7a93c084f6e63c4b64573dd11927c9f107547fade87a7415f320d1cf4c2adc8bea6a71d59c6f2b7326f84cd5710

doc/conan.string/Conan_string/index.html

Module Conan_stringSource

recognition.

Conan_string is a system-free implementation of the file recognition. This implementation does not uses any syscalls - and it can be safely used into a MirageOS example.

So Conan_string does not have an access to a database. The user must rebuild a Conan.Tree.t by himself/herself via tree_of_string for example. Then, from this tree, the user is able to recognize a payload as a simple string with run:

let v =
  {file|0       byte    0x66
  >1      byte    0x6f
  >>1     byte    0x6f    foo header
  |file}

let tree =
  match Conan_string.tree_of_string v with
  | Ok tree -> tree
  | Error (`Msg err) -> failwith err

let database = Conan.Tree.database ~tree

let m =
  match Conan_string.run ~database contents with
  | Ok m -> m
  | Error (`Msg err) -> failwith err
Sourceval tree_of_string : string -> (Conan.Tree.t, [> `Msg of string ]) result

tree_of_string str tries to parse the given str as a decision tree according to the libmagic format.

Sourceval run : database:Conan.Process.database -> string -> (Conan.Metadata.t, [> `Msg of string ]) result

run ~database contents tries to recognize the given contents with the help of database. The databse can be made via Conan.Process.database. Indeed, a Conan.Tree.t can have some indirect decision paths so we must pre-process the tree to agglomerate such indirections.