1use std::path::Path;
5#[allow(unused_imports, dead_code)]
6use tracing::{debug, error, info, trace, warn};
7
8use crate::*;
9
10#[derive(Debug, Default)]
11pub struct EmptyFileSystem {}
12
13#[allow(unused_variables)]
14impl FileSystem for EmptyFileSystem {
15 fn readlink(&self, path: &Path) -> Result<PathBuf> {
16 Err(FsError::EntryNotFound)
17 }
18
19 fn read_dir(&self, path: &Path) -> Result<ReadDir> {
20 if path == Path::new("/") {
24 Ok(ReadDir::new(Vec::new()))
25 } else {
26 Err(FsError::EntryNotFound)
27 }
28 }
29
30 fn create_dir(&self, path: &Path) -> Result<()> {
31 Err(FsError::EntryNotFound)
32 }
33
34 fn remove_dir(&self, path: &Path) -> Result<()> {
35 Err(FsError::EntryNotFound)
36 }
37
38 fn rename<'a>(&'a self, from: &'a Path, to: &'a Path) -> BoxFuture<'a, Result<()>> {
39 Box::pin(async { Err(FsError::EntryNotFound) })
40 }
41
42 fn metadata(&self, path: &Path) -> Result<Metadata> {
43 if path == Path::new("/") {
47 Ok(Metadata {
48 ft: FileType::new_dir(),
49 accessed: 0,
50 created: 0,
51 modified: 0,
52 len: 0,
53 })
54 } else {
55 Err(FsError::EntryNotFound)
56 }
57 }
58
59 fn symlink_metadata(&self, path: &Path) -> Result<Metadata> {
60 Err(FsError::EntryNotFound)
61 }
62
63 fn remove_file(&self, path: &Path) -> Result<()> {
64 Err(FsError::EntryNotFound)
65 }
66
67 fn new_open_options(&self) -> OpenOptions<'_> {
68 OpenOptions::new(self)
69 }
70}
71
72impl FileOpener for EmptyFileSystem {
73 #[allow(unused_variables)]
74 fn open(
75 &self,
76 path: &Path,
77 conf: &OpenOptionsConfig,
78 ) -> Result<Box<dyn VirtualFile + Send + Sync + 'static>> {
79 Err(FsError::EntryNotFound)
80 }
81}