rust/hg-core/src/utils.rs
changeset 46445 ca3f73cc3cf4
parent 46090 9eb07ab3f2d4
child 46483 2845892dd489
--- 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,
+    })
+}