diff --git a/judge-core/src/compiler.rs b/judge-core/src/compiler.rs index 5e89d38..f05d5d5 100644 --- a/judge-core/src/compiler.rs +++ b/judge-core/src/compiler.rs @@ -2,7 +2,7 @@ use crate::error::JudgeCoreError; use crate::utils::get_pathbuf_str; use anyhow::anyhow; use serde_derive::{Serialize, Deserialize}; -use std::fmt; +use std::{fmt, fs}; use std::path::PathBuf; use std::{process::Command, str::FromStr}; @@ -151,6 +151,10 @@ impl Compiler { target_path_string ); + if let Some(target_parent) = target_path.parent() { + fs::create_dir_all(target_parent)?; + } + if PathBuf::from(target_path).exists() { std::fs::remove_file(target_path)?; }