1234567891011121314151617181920212223242526272829303132333435363738(***********************************************************************)(* *)(* Objective Caml *)(* *)(* François Pessaux, projet Cristal, INRIA Rocquencourt *)(* Pierre Weis, projet Cristal, INRIA Rocquencourt *)(* Jun Furuse, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1999 - 2003 *)(* Institut National de Recherche en Informatique et en Automatique. *)(* Distributed only by permission. *)(* *)(***********************************************************************)(* temporary directory *)lettmp_dir=ref(trySys.getenv"CAMLIMAGESTMPDIR"withNot_found->"/tmp")letcnter=ref0letrecnew_tmp_nameprefx=incrcnter;letname=Filename.concat!tmp_dir(Printf.sprintf"camlimages-%s-%d"prefx!cnter)inifnot(Sys.file_existsname)thennameelsebeginprerr_endline("Warning: tmp file "^name^" already exists");new_tmp_nameprefxendletremove_tmp_filetmpfile=trySys.removetmpfilewith_->()letnew_tmp_file_nameprefx=ifnot(Sys.file_exists!tmp_dir)thenfailwith("Temporary directory "^!tmp_dir^" does not exist")elseletf=new_tmp_nameprefxinat_exit(fun()->remove_tmp_filef);f