From 77b17efa560462ac4681d3449027d2961f58b34c Mon Sep 17 00:00:00 2001 From: yuiveslkao Date: Mon, 6 Jan 2025 18:13:38 +0900 Subject: [PATCH] =?UTF-8?q?droptrait=E3=82=92=E5=85=A5=E3=82=8C=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- judge_control_app/src/custom_rc/readonly_file.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/judge_control_app/src/custom_rc/readonly_file.rs b/judge_control_app/src/custom_rc/readonly_file.rs index 61e2d2d..68bb5aa 100644 --- a/judge_control_app/src/custom_rc/readonly_file.rs +++ b/judge_control_app/src/custom_rc/readonly_file.rs @@ -27,6 +27,20 @@ impl ReadonlyFile { } } +impl Drop for ReadonlyFile { + fn drop(&mut self) { + let result = std::fs::remove_file(&self.path).context(format!( + "Failed to remove file while dropping ReadonlyFile : {:?}", + self.path + )); + match result { + Ok(_) => {} + Err(e) => { + eprintln!("{:?}", e); + } + } + } +} impl super::File for ReadonlyFile { fn path(&self) -> PathBuf { self.path.clone()