Crates.io | homedir |
lib.rs | homedir |
version | 0.3.4 |
source | src |
created_at | 2023-08-13 00:02:38.245948 |
updated_at | 2024-10-01 01:50:51.734423 |
description | A crate to help get the home directory of any user on a system. |
homepage | https://jamespetersen.ca/homedir |
repository | https://github.com/ljtpetersen/homedir |
max_upload_size | |
id | 943047 |
size | 50,446 |
This crate exists to provide a portable method to getting any user's home
directory. The API is rather simple: there are two main functions,
home
and my_home
. The former can get the home directory
of any user provided you have their username. The latter can get the home
directory of the user executing this process.
If all that is necessary is the home directory of the user executing this process,
then other crates may be better options, such as
directories
. As well, using the home directory to find the
documents, downloads, pictures, etc. directories may not be accurate.
This crate aims to work on both Windows and Unix systems. However,
Unix systems do not have a unified API. This crate may not work
on Unix systems which do not have the getpwnam_r(3)
, getpwuid_r(3)
,
and getuid(2)
functions. As well, special care is necessary for Windows
programs which use the COM library in other places. See the "For Windows Users" section
in the crate documentation for more details.
This crate is on crates.io and can be used by executing cargo add homedir
or adding the following to the dependencies in your Cargo.toml
file.
[dependencies]
homedir = "0.3.4"
windows-coinitialize
-- This is enabled by default. On Windows, call CoInitializeEx
if CoCreateInstance
returns CO_E_NOTINITIALIZED
.
See the "For Windows Users" section of the documentation for details about CoInitializeEx
.The full documentation of the crate, including examples, is available on the docs.rs page.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Feel free to put a copyright header in your name in any files you contribute to.
Copyright (C) 2023-2024 James Petersen m@jamespetersen.ca.
In version 0.3.0
, the wmi-rs
crate was referenced when writing the
homedir::windows::UserIdentifier::to_home
function, though there may not be any resemblance now. Nevertheless, I felt it was important to properly credit them, hence I included
this statement here. The referenced repository is also licensed under APACHE and MIT, which are included in this repository.