equal
deleted
inserted
replaced
8 sig |
8 sig |
9 val isabelle_tool: string -> string -> int |
9 val isabelle_tool: string -> string -> int |
10 val mkdirs: Path.T -> unit |
10 val mkdirs: Path.T -> unit |
11 val mkdir: Path.T -> unit |
11 val mkdir: Path.T -> unit |
12 val copy_dir: Path.T -> Path.T -> unit |
12 val copy_dir: Path.T -> Path.T -> unit |
13 val with_tmp_file: string -> (Path.T -> 'a) -> 'a |
13 val create_tmp_path: string -> string -> Path.T |
|
14 val with_tmp_file: string -> string -> (Path.T -> 'a) -> 'a |
14 val with_tmp_dir: string -> (Path.T -> 'a) -> 'a |
15 val with_tmp_dir: string -> (Path.T -> 'a) -> 'a |
15 end; |
16 end; |
16 |
17 |
17 structure Isabelle_System: ISABELLE_SYSTEM = |
18 structure Isabelle_System: ISABELLE_SYSTEM = |
18 struct |
19 struct |
48 else (system_command ("cp -r -f " ^ File.shell_path src ^ "/. " ^ File.shell_path dst); ()); |
49 else (system_command ("cp -r -f " ^ File.shell_path src ^ "/. " ^ File.shell_path dst); ()); |
49 |
50 |
50 |
51 |
51 (* unique tmp files *) |
52 (* unique tmp files *) |
52 |
53 |
53 local |
54 fun create_tmp_path name ext = |
54 |
|
55 fun fresh_path name = |
|
56 let |
55 let |
57 val path = File.tmp_path (Path.basic (name ^ serial_string ())); |
56 val path = File.tmp_path (Path.basic (name ^ serial_string ()) |> Path.ext ext); |
58 val _ = File.exists path andalso |
57 val _ = File.exists path andalso |
59 raise Fail ("Temporary file already exists: " ^ Path.print path); |
58 raise Fail ("Temporary file already exists: " ^ Path.print path); |
60 in path end; |
59 in path end; |
61 |
60 |
|
61 fun with_tmp_file name ext f = |
|
62 let val path = create_tmp_path name ext |
|
63 in Exn.release (Exn.capture f path before ignore (try File.rm path)) end; |
|
64 |
62 fun rm_tree path = system_command ("rm -r -f " ^ File.shell_path path); |
65 fun rm_tree path = system_command ("rm -r -f " ^ File.shell_path path); |
63 |
|
64 in |
|
65 |
|
66 fun with_tmp_file name f = |
|
67 let val path = fresh_path name |
|
68 in Exn.release (Exn.capture f path before ignore (try File.rm path)) end; |
|
69 |
66 |
70 fun with_tmp_dir name f = |
67 fun with_tmp_dir name f = |
71 let |
68 let |
72 val path = fresh_path name; |
69 val path = create_tmp_path name ""; |
73 val _ = mkdirs path; |
70 val _ = mkdirs path; |
74 in Exn.release (Exn.capture f path before ignore (try rm_tree path)) end; |
71 in Exn.release (Exn.capture f path before ignore (try rm_tree path)) end; |
75 |
72 |
76 end; |
73 end; |
77 |
74 |
78 end; |
|
79 |
|