patch #8333
[mldonkey.git] / tools / svg_converter.ml
blob8e3da0e57893f741e2030f6c23fdfe55cbc97461
1 (* Copyright 2004 b8_bavard, INRIA *)
2 (*
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 open Filename2
22 open Zlib
24 let load_svg file =
25 Printf.printf "Converting file %s\n" file;
26 flush stdout;
27 let ic = open_in_bin file in
28 let len = in_channel_length ic in
29 let buf = String.create len in
30 really_input ic buf 0 len;
31 close_in ic;
32 let bufz = compress_string buf in
33 let basename = basename file in
34 let extension = last_extension basename in
35 let dirname = String.sub file 0 (String.length file - String.length basename) in
36 let len = String.length basename - String.length extension in
37 let name = String.sub basename 0 len in
38 let oc = open_out_bin (dirname ^ name ^ "_svg.ml") in
39 output_string oc (Printf.sprintf "let t =" );
40 output_string oc (Printf.sprintf "%S" bufz);
41 close_out oc
43 let _ =
44 if Array.length Sys.argv < 2 then begin
45 Printf.eprintf "usage : %s <file>\n" Sys.argv.(0);
46 exit 2;
47 end;
48 load_svg Sys.argv.(1)