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