about summary refs log tree commit diff
path: root/splorm/src/fs
diff options
context:
space:
mode:
Diffstat (limited to 'splorm/src/fs')
-rw-r--r--splorm/src/fs/mod.rs9
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),
 	}
 }