diff options
| author | gennyble <gen@nyble.dev> | 2026-09-24 01:52:48 -0500 |
|---|---|---|
| committer | gennyble <gen@nyble.dev> | 2026-09-24 01:52:48 -0500 |
| commit | f2a9bc39cb9aa8a9d9e186bfd71dfd2405fe1ab6 (patch) | |
| tree | 9a5fdc35930ce7d0a039fe5eae154555cf0231fb /splorm/src/fs | |
| parent | 32cbf8332bdaafae8c0934ff2ab45048bc8f2361 (diff) | |
splorm, meow
Diffstat (limited to 'splorm/src/fs')
| -rw-r--r-- | splorm/src/fs/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/splorm/src/fs/mod.rs b/splorm/src/fs/mod.rs index 032aaed..8450db7 100644 --- a/splorm/src/fs/mod.rs +++ b/splorm/src/fs/mod.rs @@ -1,5 +1,6 @@ mod request_path; +use camino::Utf8PathBuf; pub use request_path::{Mime, Mimetype, RequestPath, SafePath, SafePathBuf}; use tokio::fs::File; @@ -13,8 +14,12 @@ pub async fn open_file<'p>(path: SafePath<'p>) -> Result<File, RuntimeError> { pub async fn read_file<'p>(path: SafePath<'p>) -> Result<Vec<u8>, RuntimeError> { let system_path = *path; - match tokio::fs::read(system_path).await { - Err(err) => Err(RuntimeError::file_error(err, system_path.to_path_buf())), + unsafe_read_file(system_path.to_owned()).await +} + +pub async fn unsafe_read_file(path: Utf8PathBuf) -> Result<Vec<u8>, RuntimeError> { + match tokio::fs::read(&path).await { + Err(err) => Err(RuntimeError::file_error(err, path)), Ok(vec) => Ok(vec), } } |
