feat(sdk,plugins): API publique d'accès fichiers/workspace + analyse structure (#124,#129)
This commit is contained in:
@ -9,7 +9,7 @@ use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::ports::{DirEntry, FileSystem, FsError, RemotePath};
|
||||
use domain::ports::{DirEntry, FileMetadata, FileSystem, FsError, RemotePath};
|
||||
use tokio::fs;
|
||||
|
||||
/// Filesystem adapter backed by the local OS via `tokio::fs`.
|
||||
@ -54,6 +54,17 @@ impl FileSystem for LocalFileSystem {
|
||||
}
|
||||
}
|
||||
|
||||
async fn metadata(&self, path: &RemotePath) -> Result<FileMetadata, FsError> {
|
||||
let meta = fs::metadata(path.as_str())
|
||||
.await
|
||||
.map_err(|e| map_io(path, &e))?;
|
||||
Ok(FileMetadata {
|
||||
is_file: meta.is_file(),
|
||||
is_dir: meta.is_dir(),
|
||||
len: Some(meta.len()),
|
||||
})
|
||||
}
|
||||
|
||||
async fn remove_file(&self, path: &RemotePath) -> Result<(), FsError> {
|
||||
match fs::remove_file(path.as_str()).await {
|
||||
Ok(()) => Ok(()),
|
||||
|
||||
Reference in New Issue
Block a user