Skip to main content

file_storage/op/file/exists/
exists.rs

1use crate::LocalPath;
2use crate::Operation::Exists;
3use crate::Reason::UnknownFileSystem;
4use crate::{Error, FilePath};
5
6impl FilePath {
7    //! Exists
8
9    /// Checks if the file exists.
10    pub fn exists(&self) -> Result<bool, Error> {
11        if let Some(path) = LocalPath::from(self.path()) {
12            return path.exists();
13        }
14
15        #[cfg(feature = "r2")]
16        if let Some(path) = crate::R2Path::from(self.path()) {
17            return path.exists();
18        }
19
20        Err(Error::new(self.clone(), Exists, UnknownFileSystem))
21    }
22}