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.
  match get('HOME') {
    case Ok(v) if v.size > 0 -> Option.Some(Path.new(v))
    case _ -> 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')