Skip to content
This repository
Newer
Older
100644 43 lines (33 sloc) 1.432 kb
fccc6851 »
2011-06-21 Initial open-source release
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (**
20 Some functions used by compilation passes.
21 *)
22
23 (* -- *)
24
25 let slash2filename f =
26 let n = String.length f in
27 let buf = Buffer.create n in
28 for i = 0 to n-1 do
29 if f.[i] = '/' then
30 Buffer.add_string buf File.path_sep
31 else Buffer.add_char buf f.[i]
32 done;
33 Buffer.contents buf
34
35 (** new version of StaticsInclude : see file ofile.ml *)
36 let file_content_and_embedded ?(warn_no_embedded=false) f = match StaticsInclude.get_file f with
37 | Some c -> c
38 | None -> (if warn_no_embedded then prerr_endline (Printf.sprintf "%s is not embedded" f)); File.content (PathTransform.string_to_mysys f)
39
40 let output fname s =
41 if not (File.output fname s) then
42 failwith (Printf.sprintf "Can't write file \"%s\" (current path is \"%s\")" fname (Sys.getcwd ()))
Something went wrong with that request. Please try again.