Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file owl_zoo_path.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647(*
* OWL - OCaml Scientific and Engineering Computing
* Copyright (c) 2016-2020 Liang Wang <liang.wang@cl.cam.ac.uk>
*)(* Root of Zoo System *)letdir=Sys.getenv"HOME"^"/.owl/zoo"(* Path of Zoo version database *)lethtb=dir^"/"^"zoo_ver.htb"(* Used internally *)letgist_pathgidvid=dir^"/"^gid^"/"^vid(* Used by script developers *)letextend_zoo_path?(gid="")?(vid="")filepath=matchgid,vidwith|"",""->filepath|g,v->gist_pathgv^"/"^filepath(* Make temporary directory *)letmk_temp_dir?(mode=0o700)?dirpat=letdir=matchdirwith|Somed->d|None->Filename.get_temp_dir_name()inletrand_digits()=letrand=Random.State.(bits(make_self_init())land0xFFFFFF)inPrintf.sprintf"%06x"randinletraise_errmsg=raise(Sys_error("mk_temp_dir: "^msg))inletrecloopcount=ifcount<0thenraise_err"too many failing attemps"else(letdir=Printf.sprintf"%s/%s%s"dirpat(rand_digits())intryUnix.mkdirdirmode;dirwith|Unix.Unix_error(Unix.EEXIST,_,_)->loop(count-1)|Unix.Unix_error(Unix.EINTR,_,_)->loopcount|Unix.Unix_error(e,_,_)->raise_err(Unix.error_messagee))inloop1000