From b278a6aa52acb583b3393790e198302fa0a60c16 Mon Sep 17 00:00:00 2001 From: Oleg Sobolev Date: Mon, 1 Apr 2024 09:06:48 +0700 Subject: [PATCH] implement FileHandle --- src/file.rs | 21 +++++++++++++++++++++ src/lib.rs | 1 + 2 files changed, 22 insertions(+) create mode 100644 src/file.rs diff --git a/src/file.rs b/src/file.rs new file mode 100644 index 0000000..37375a7 --- /dev/null +++ b/src/file.rs @@ -0,0 +1,21 @@ +use std::path::{Path, PathBuf}; +use std::fs; + +#[derive(Debug, Clone)] +pub struct FileHandle { + path: PathBuf, +} + +impl FileHandle { + pub fn new(path: &Path) -> FileHandle { + FileHandle { + path: PathBuf::from(path), + } + } +} + +impl Drop for FileHandle { + fn drop(&mut self) { + let _ = fs::remove_file(self.path.clone()); + } +} diff --git a/src/lib.rs b/src/lib.rs index 6f1f52b..61ca117 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod channel; pub mod download; +pub mod file; pub mod player; pub mod telegram; mod track;