create dirs + delete dirs + delete files
This commit is contained in:
@@ -36,3 +36,21 @@ where
|
||||
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
pub async fn create_dir<P>(path: P) -> Result<()>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
fs::create_dir(path).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_dir<P>(path: P) -> Result<()>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
fs::remove_dir_all(path).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
14
backend/src/fs/file.rs
Normal file
14
backend/src/fs/file.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use std::path::Path;
|
||||
|
||||
use tokio::fs;
|
||||
|
||||
use crate::Result;
|
||||
|
||||
pub async fn delete_file<P>(path: P) -> Result<()>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
fs::remove_file(path).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
mod dir;
|
||||
mod file;
|
||||
pub use dir::*;
|
||||
pub use file::*;
|
||||
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum FileType {
|
||||
File,
|
||||
|
||||
Reference in New Issue
Block a user