Search results

There are no results.

std.env.home_directory

Show source code
Hide source code
fn pub home_directory -> Option[Path] {
  # Rather than performing all sorts of magical incantations to get the home
  # directory, we're just going to require that HOME is set.
  #
  # If the home is explicitly set to an empty string we still ignore it, because
  # there's no scenario in which Some("") is useful.
  let val = match inko_env_get(_INKO.state, 'HOME') {
    case { @tag = 0, @value = val } -> val as String
    case _ -> return Option.None
  }

  if val.size > 0 { Option.Some(Path.new(val)) } else { Option.None }
}
fn pub static home_directory -> Option[Path]

Returns the path to the current user's home directory.

Examples

Obtaining the home directory of a user:

import std.env

env.home_directory # => Option.Some('/home/alice')