Provide a current user home directory API in FileSystem
Currently NIOFileSystem offers current working directory and temp working directory as a way to get various directories. It would be great to provide an API to get the user's current working directory, equivalent to FileManager.default.homeDirectoryForCurrentUser
Thanks for the issue Tim, I'm curious do you currently have any workarounds for this, is it blocking any functionality?
Nothing really blocking at the moment, workaround is either read $HOME or just use the FileManager API
Thanks for the context 🙏
If anyone feels like tackling this from the OSS side, the strategy is this:
- First check the value of the
HOMEenvironment variable. If set, assume that's the home directory. - If not set, use
getpwuid_rwith the return value ofgetuid()and load the home directory from there.
Im working on this issue.