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 fn mount(
72 &self,
73 name: String,
74 path: &Path,
75 fs: Box<dyn crate::FileSystem + Send + Sync>,
76 ) -> Result<()> {
77 Err(FsError::Unsupported)
78 }
79}
80
81impl FileOpener for EmptyFileSystem {
82 #[allow(unused_variables)]
83 fn open(
84 &self,
85 path: &Path,
86 conf: &OpenOptionsConfig,
87 ) -> Result<Box<dyn VirtualFile + Send + Sync + 'static>> {
88 Err(FsError::EntryNotFound)
89 }
90}