package conan

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

Install

Dune Dependency

Authors

Maintainers

Sources

conan-cli-v0.0.1.tbz
sha256=625185d23c980636b90d245eae4e48d41ffcb14d6a2712c57c40e2bfd0102ff7
sha512=2b8592f7df6cc369039a1b40eff951e5006099350b347d2f92af270e5eb7ff74de0ed21d595a1e7e7955aa1ad65432d24288a468641c6340a12e40e7be21ac0e

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 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.

OCaml

Innovation. Community. Security.

On This Page
  1. recognition.