swift-nio icon indicating copy to clipboard operation
swift-nio copied to clipboard

Provide a current user home directory API in FileSystem

Open 0xTim opened this issue 3 months ago • 5 comments

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

0xTim avatar Sep 24 '25 01:09 0xTim

Thanks for the issue Tim, I'm curious do you currently have any workarounds for this, is it blocking any functionality?

rnro avatar Sep 24 '25 08:09 rnro

Nothing really blocking at the moment, workaround is either read $HOME or just use the FileManager API

0xTim avatar Sep 24 '25 09:09 0xTim

Thanks for the context 🙏

rnro avatar Sep 24 '25 10:09 rnro

If anyone feels like tackling this from the OSS side, the strategy is this:

  1. First check the value of the HOME environment variable. If set, assume that's the home directory.
  2. If not set, use getpwuid_r with the return value of getuid() and load the home directory from there.

Lukasa avatar Sep 25 '25 10:09 Lukasa

Im working on this issue.

cnaples79 avatar Sep 30 '25 22:09 cnaples79