Skip to content

Commit d593fd1

Browse files
committed
[plotkicadsch] fix output in case of absolute paths
1 parent 65aa2c6 commit d593fd1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

plotkicadsch/src/plotkicadsch.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ open Kicadsch
22
module SvgSchPainter = MakeSchPainter(SvgPainter)
33
open SvgSchPainter
44

5+
let build_outputfilename outdir sch =
6+
let open Filename in
7+
let basefilename =
8+
if String.equal outdir "" then
9+
sch
10+
else
11+
concat outdir (basename sch) in
12+
(remove_extension basefilename) ^ ".svg"
13+
514
let process_file init outdir sch =
6-
let slen = String.length sch in
7-
let fileout = outdir ^ "/" ^(String.sub sch 0 (slen - 4)) ^ ".svg" in
15+
let fileout = build_outputfilename outdir sch in
816
let%lwt o = Lwt_io.open_file ~mode:Lwt_io.Output fileout in
917
let%lwt i = Lwt_io.open_file ~mode:Lwt_io.Input sch in
1018
let%lwt endcontext = Lwt_stream.fold parse_line (Lwt_io.read_lines i) init in
@@ -19,7 +27,7 @@ let process_libs libs =
1927
let () =
2028
let files = ref [] in
2129
let libs = ref [] in
22-
let outpath = ref "." in
30+
let outpath = ref "" in
2331
let speclist = [
2432
("-l", Arg.String (fun lib -> libs := lib::!libs), "specify component library");
2533
("-f", Arg.String(fun sch -> files := sch::!files), "sch file to process");

0 commit comments

Comments
 (0)