rapx/analysis/unsafety_isolation/
draw_dot.rs1use std::fs::{remove_file, File};
2use std::io::Write;
3use std::process::Command;
4
5pub fn render_dot_graphs(dot_graphs: Vec<String>) {
7 Command::new("mkdir")
8 .args(["UPG"])
9 .output()
10 .expect("Failed to create directory");
11
12 for (index, dot) in dot_graphs.into_iter().enumerate() {
13 let file_name = format!("graph{}.dot", index);
14 let mut file = File::create(&file_name).expect("Unable to create file");
15 file.write_all(dot.as_bytes())
16 .expect("Unable to write data");
17
18 Command::new("dot")
19 .args([
20 "-Tpng",
21 &file_name,
22 "-o",
23 &format!("UPG/graph{}.png", index),
24 ])
25 .output()
26 .expect("Failed to execute Graphviz dot command");
27
28 remove_file(&file_name).expect("Failed to delete .dot file");
29 }
30}