-(** .metadata file format
- * - an integer -- magic number -- denoting the version of the dumped data
- * structure. Different magic numbers stand for incompatible data structures
- * - an integer -- checksum -- denoting the hash value (computed with
- * Hashtbl.hash) of the string representation of the dumped data structur
- * - marshalled data: list of metadata
- *)
-
-let save_metadata ~fname metadata =
- let ensure_path_exists path =
- let dir = Filename.dirname path in
- HExtlib.mkdir dir
- in
- ensure_path_exists fname;
- let oc = open_out fname in
- let marshalled = Marshal.to_string metadata marshal_flags in
- let checksum = Hashtbl.hash marshalled in
- output_binary_int oc magic;
- output_binary_int oc checksum;
- output_string oc marshalled;
- close_out oc
+let load_metadata_from_file ~fname =
+ let raw = HMarshal.load ~fmt:format_name ~version:magic ~fname in
+ (raw: metadata list)