~ubuntu-branches/debian/squeeze/camlimages/squeeze

« back to all changes in this revision

Viewing changes to src/tmpfile.ml

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Le Gall, Ralf Treinen, Sylvain Le Gall
  • Date: 2009-03-05 00:19:32 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090305001932-f0hstlmun8hxvs0r
Tags: 1:3.0.1-1
[ Ralf Treinen ]
* Updated debian/watch.

[ Sylvain Le Gall ]
* New upstream version:
  * Remove useless patches
  * Adapt debian/rules and other debhelper files
  * Add debian/patches/fix_3_0_1 to fix various problem (probably due to
    OCaml 3.11 migration)
* Depends on version 2.12 of lablgtk2
* Add dh-ocaml build-dependency (rules/ocaml.mk)
* Add ${misc:Depends} to dependencies
* Update Homepage field into debian/control and debian/copyright
* Add license version for debian packaging
* Directly use eng.html rather than creating a linked index.html file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(***********************************************************************)
 
2
(*                                                                     *)
 
3
(*                           Objective Caml                            *)
 
4
(*                                                                     *)
 
5
(*            Fran�ois Pessaux, projet Cristal, INRIA Rocquencourt     *)
 
6
(*            Pierre Weis, projet Cristal, INRIA Rocquencourt          *)
 
7
(*            Jun Furuse, projet Cristal, INRIA Rocquencourt           *)
 
8
(*                                                                     *)
 
9
(*  Copyright 1999 - 2003                                              *)
 
10
(*  Institut National de Recherche en Informatique et en Automatique.  *)
 
11
(*  Distributed only by permission.                                    *)
 
12
(*                                                                     *)
 
13
(***********************************************************************)
 
14
 
 
15
(* temporary directory *)
 
16
let tmp_dir = ref (try Sys.getenv "CAMLIMAGESTMPDIR" with Not_found -> "/tmp");;
 
17
 
 
18
let cnter = ref 0;;
 
19
 
 
20
let rec new_tmp_name prefx =
 
21
  incr cnter;
 
22
  let name =
 
23
    Filename.concat !tmp_dir
 
24
      (Printf.sprintf "camlimages-%s-%d" prefx !cnter) in
 
25
  if not (Sys.file_exists name) then name else begin
 
26
    prerr_endline ("Warning: tmp file " ^ name ^ " already exists");
 
27
    new_tmp_name prefx
 
28
  end;;
 
29
 
 
30
let remove_tmp_file tmpfile = try Sys.remove tmpfile with _ -> ();;
 
31
 
 
32
let new_tmp_file_name prefx =
 
33
  if not (Sys.file_exists !tmp_dir) then 
 
34
    failwith ("Temporary directory " ^ !tmp_dir ^ " does not exist") else
 
35
  let f = new_tmp_name prefx in
 
36
  at_exit (fun () -> remove_tmp_file f);
 
37
  f;;
 
38