1234567891011121314151617181920212223242526272829303132333435(*****************************************************************************)(* *)(* Copyright (C) 2026 Yves Ndiaye *)(* *)(* This Source Code Form is subject to the terms of the Mozilla Public *)(* License, v. 2.0. If a copy of the MPL was not distributed with this *)(* file, You can obtain one at https://mozilla.org/MPL/2.0/. *)(* *)(*****************************************************************************)(** [make_path_safe s] replaces all {i slash}, {i backslash} and {i 0x00}
characters by {i _} *)letmake_path_safes=String.map(function'/'|'\\'|'\000'->'_'|c->c)sletrecchunkscurrentaccns=matchswith|[]->acc|t::q->(lets=Printf.sprintf"%s%c"currenttinmatchString.lengthswith|lwhenl=n->chunksString.empty(s::acc)nq|_->chunkssaccnq)(** [chunks n s] sépare [s] en une liste de [n] strings *)letchunks?(rev=false)ns=lets=chunksString.empty[]n(List.of_seq@@String.to_seqs)inifrevthenselseList.revs