summaryrefslogtreecommitdiff
path: root/matrix-std/src/sys.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-02-29 21:05:10 -0500
committerFreya Murphy <freya@freyacat.org>2024-02-29 21:05:10 -0500
commitace046624d2e23fba67564a86af7f03ed8a48eae (patch)
tree21ae64bc5897b1b89ee2ab8563b0e7ce047bf34a /matrix-std/src/sys.rs
parentfix readme (diff)
downloadmatrix-ace046624d2e23fba67564a86af7f03ed8a48eae.tar.gz
matrix-ace046624d2e23fba67564a86af7f03ed8a48eae.tar.bz2
matrix-ace046624d2e23fba67564a86af7f03ed8a48eae.zip
remove unwraps, fix utf8
Diffstat (limited to 'matrix-std/src/sys.rs')
-rw-r--r--matrix-std/src/sys.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/matrix-std/src/sys.rs b/matrix-std/src/sys.rs
index 609e72d..8b54f0f 100644
--- a/matrix-std/src/sys.rs
+++ b/matrix-std/src/sys.rs
@@ -193,7 +193,7 @@ fn basename(_: VmArgs, args: Vec<Value>) -> Result<Value> {
};
let path = PathBuf::from(value.to_string());
match path.file_name() {
- Some(p) => Ok(Value::String(p.to_str().unwrap().into())),
+ Some(p) => Ok(Value::String(p.to_str().unwrap_or("").into())),
None => Ok(Value::String(value.into()))
}
}
@@ -209,7 +209,7 @@ fn dirname(_: VmArgs, args: Vec<Value>) -> Result<Value> {
Some(p) => p,
None => path.as_path()
};
- let str = parent.as_os_str().to_str().unwrap();
+ let str = parent.as_os_str().to_str().unwrap_or("");
match str {
"" => Ok(Value::String(".".into())),
s => Ok(Value::String(s.into()))
@@ -226,7 +226,7 @@ fn realpath(_: VmArgs, args: Vec<Value>) -> Result<Value> {
Ok(p) => p,
Err(e) => return error!("could not get realpath: {e}")
};
- Ok(Value::String(path.to_str().unwrap().into()))
+ Ok(Value::String(path.to_str().unwrap_or("").into()))
}