use std::fs::{self, OpenOptions}; use std::env; use std::path::Path; use std::process::{Command, Stdio}; use std::thread; use std::time::Duration; use std::io::{Write, Seek, SeekFrom}; fn main() { let args: Vec<_> = env::args_os().collect(); if args.len() == 2 { let js_file = Path::new(&args[1]); while !js_file.exists() { thread::sleep(Duration::from_millis(0)); } let mut file = OpenOptions::new().write(true).open(js_file).unwrap(); file.seek(SeekFrom::End(-16)).unwrap(); let _ = writeln!(file, "\n"); } else { let out_dir = env::var("OUT_DIR").unwrap(); let target_dir = Path::new(&out_dir).parent().unwrap().parent().unwrap().parent().unwrap().parent().unwrap(); let js_file = target_dir.join("doc/xss_probe/index.html"); if js_file.exists() { let _ = fs::remove_file(&js_file); } let mut cmd = Command::new(env::current_exe().unwrap()); cmd.arg(js_file); cmd.stderr(Stdio::null()); cmd.stdin(Stdio::null()); cmd.stdout(Stdio::null()); cmd.spawn().unwrap(); } }