Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file owl_zoo_path.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445(*
* OWL - OCaml Scientific and Engineering Computing
* Copyright (c) 2016-2019 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"elseletdir=Printf.sprintf"%s/%s%s"dirpat(rand_digits())intry(Unix.mkdirdirmode;dir)with|Unix.Unix_error(Unix.EEXIST,_,_)->loop(count-1)|Unix.Unix_error(Unix.EINTR,_,_)->loopcount|Unix.Unix_error(e,_,_)->raise_err(Unix.error_messagee)inloop1000