implement FileHandle
This commit is contained in:
parent
959f954d9d
commit
b278a6aa52
2 changed files with 22 additions and 0 deletions
21
src/file.rs
Normal file
21
src/file.rs
Normal file
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
pub mod channel;
|
||||
pub mod download;
|
||||
pub mod file;
|
||||
pub mod player;
|
||||
pub mod telegram;
|
||||
mod track;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue