File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ homepage = "https://github.com/iancleary/touchstone"
77license = " MIT"
88name = " touchstone"
99repository = " https://github.com/iancleary/touchstone"
10- version = " 0.7.1 "
10+ version = " 0.7.2 "
1111
1212# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313
Original file line number Diff line number Diff line change 1+ use std:: path:: Path ;
2+
13// The paths are relative to this .rs file
24pub ( crate ) static PLOTLY_JS : & str = include_str ! ( "assets/js/plotly-3.3.0.min.js" ) ;
35// pub (crate) static PLOTLY_SRC_LINE: &str = "./js/plotly-3.3.0.min.js";
@@ -54,7 +56,14 @@ pub fn generate_two_port_plot_html(
5456 s12_data : & str ,
5557 s22_data : & str ,
5658) -> std:: io:: Result < ( ) > {
57- let folder_path = std:: path:: Path :: new ( output_path) . parent ( ) . unwrap ( ) ;
59+
60+ // this only works if a relative path or full path is given.
61+ // the unwrap fails if "ntwk1.s2p" is given instead of "./ntwk1.s2p"
62+ // Attempt to get parent; if None, default to "." (current dir)
63+ let folder_path = Path :: new ( output_path)
64+ . parent ( )
65+ . map ( |p| if p. as_os_str ( ) . is_empty ( ) { Path :: new ( "." ) } else { p } )
66+ . unwrap_or ( Path :: new ( "." ) ) ;
5867 std:: fs:: create_dir_all ( folder_path) ?;
5968
6069 let mut html_content = include_str ! ( "assets/template_2port.html" ) . to_string ( ) ;
You can’t perform that action at this time.
0 commit comments