--- a/rust/hg-core/src/utils.rs Thu Jan 28 19:21:57 2021 +0100
+++ b/rust/hg-core/src/utils.rs Thu Jan 28 19:13:55 2021 +0100
@@ -7,6 +7,7 @@
//! Contains useful functions, traits, structs, etc. for use in core.
+use crate::errors::{HgError, IoErrorContext};
use crate::utils::hg_path::HgPath;
use std::{io::Write, ops::Deref};
@@ -176,3 +177,10 @@
None
}
}
+
+pub fn current_dir() -> Result<std::path::PathBuf, HgError> {
+ std::env::current_dir().map_err(|error| HgError::IoError {
+ error,
+ context: IoErrorContext::CurrentDir,
+ })
+}