| Crates.io | pathexpand |
| lib.rs | pathexpand |
| version | 0.1.1 |
| created_at | 2025-01-27 20:48:18.617214+00 |
| updated_at | 2025-03-22 22:28:52.660699+00 |
| description | simple and lightweight crate for expanding homedirs and env variables in paths |
| homepage | https://git.gay/tauon/pathexpand |
| repository | https://git.gay/tauon/pathexpand |
| max_upload_size | |
| id | 1532857 |
| size | 14,150 |
pathexpandsimple and lightweight rust crate to expand homedirs and env variables in paths.
can expand:
~~user is user's home directory${VAR} or ${VAR2:alternative if undefined}. this is the only syntax, %VAR% and $VAR do not work.syntax remains the same on all platforms. ~user only works on systems where /etc/passwd exists and is readable. (i.e., not windows)
this contains a crappy implementation of the pwd crate (and similar crates) for now, because i want to use the least amount of unsafe code possible. i wrote this crate for doing a config dir in programs i write, because i couldn't find a library that expanded paths in the way i wanted, so i just wanted to get it done quickly. i'll eventually write a crate for users, groups, and passwords later, like a safe version of the users crate.
unsafe code is required to determine what the current user is. unsafe code is forbidden if the unsafe-code feature is disabled, but this means that expanding ~ in paths will no longer work. on linux, the getuid syscall is used, and on other platforms, libc::getuid() is used.