123456789101112131415161718192021222324252627282930313233343536373839(************************************************************************)(* * The Rocq Prover / The Rocq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)letre_delim=Str.regexp(ifSys.win32then"[/\\]+"else"/+")letto_relative_path:string->string=funfull_path->ifFilename.is_relativefull_paththenfull_pathelseletcwd=Str.split_delimre_delim(Sys.getcwd())inletpath=Str.split_delimre_delimfull_pathinletrecremove_common_prefixl1l2=match(l1,l2)with|(x1::l1,x2::l2)whenx1=x2->remove_common_prefixl1l2|(_,_)->(l1,String.concat"/"l2)inlet(cwd,path)=remove_common_prefixcwdpathinletadd_parentpath_=Filename.concatFilename.parent_dir_namepathinList.fold_leftadd_parentpathcwdletnormalize_path:string->string=funpath->letpath=Str.split_delimre_delimpathinletrecnormalizeaccpath=match(path,acc)with|([],_)->List.revacc|("."::path,_)->normalizeaccpath|(".."::path,[])->normalize(".."::[])path|(".."::path,".."::_)->normalize(".."::acc)path|(".."::path,_::acc)->normalizeaccpath|(dir::path,_)->normalize(dir::acc)pathinmatchnormalize[]pathwith|[]->"."|path->String.concat"/"path