package conan
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=b210257b881715ffb9dcbf88678c8559ec2aef26795a5304afd5a8b4bbf11e16
sha512=5b46c70c237a6c40b1119bdc33e30fb4911d9f60e5b6bc3976604a0a4bd17635ecbb0862b9944e6022090ab0f1d01bd5e1832b465a7c2c5328e88d7cf23c2e40
doc/conan.string/Conan_string/index.html
Module Conan_string
Source
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
tree_of_string str
tries to parse the given str
as a decision tree according to the libmagic
format.
val 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.