std.env.working_directory
Show source codeHide source code
fn pub working_directory -> Result[Path, Error] {
match inko_env_get_working_directory(_INKO.state) {
case { @tag = 0, @value = val } -> Result.Ok(Path.new(val as String))
case { @tag = _, @value = err } -> {
Result.Error(Error.from_os_error(err as Int))
}
}
}
fn pub static working_directory -> Result[Path, Error]
Returns the current working directory.
This method will return an Error
if we failed to get the directory. Possible
causes for this could be:
- The directory no longer exists.
- You do not have the permissions to access the directory.
Examples
Obtaining the current working directory:
import std.env
env.working_directory # => Result.Ok('/home/alice/example')