Skip to content

Conversation

@PhantomInTheWire
Copy link
Contributor

Add homeDirectory accessor to FileSystem

Motivation:

Addresses #3381 by adding a homeDirectory property to FileSystem, equivalent to FileManager.default.homeDirectoryForCurrentUser.

Modifications:

  • Added homeDirectory property to FileSystemProtocol and implemented in FileSystem
  • Implementation checks HOME environment variable first, falls back to USERPROFILE on Windows, or uses getpwuid_r(3) on POSIX systems
  • Added system call wrappers (system_getuid, libc_getpwuid_r) with proper platform guards
  • Added FileSystemError.getpwuid_r() error helper

Result:

Users can now access the home directory via FileSystem.homeDirectory, returning a FilePath asynchronously. Follows the same pattern as currentWorkingDirectory and temporaryDirectory.

@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Jan 5, 2026
@PhantomInTheWire
Copy link
Contributor Author

rebased to master. @Lukasa shoudl i be worried about this in ci?

1 breaking change detected in _NIOFileSystem:
💔 API breakage: var FileSystemProtocol.homeDirectory has been added as a protocol requirement
Error: Process completed with exit code 1.

@Lukasa
Copy link
Contributor

Lukasa commented Jan 6, 2026

No, this is acceptable.

@PhantomInTheWire
Copy link
Contributor Author

image ci failure seems unrelated

@Lukasa Lukasa enabled auto-merge (squash) January 8, 2026 11:45
@PhantomInTheWire
Copy link
Contributor Author

@Lukasa just to confirm this will get auto merged the next time swift nio has a semver minor or major right? (sorry if this is too basic of question to ask, but im just confused)

@Lukasa Lukasa disabled auto-merge January 12, 2026 15:10
@Lukasa
Copy link
Contributor

Lukasa commented Jan 12, 2026

API breakage is expected, merging over it.

@Lukasa Lukasa merged commit 608e511 into apple:main Jan 12, 2026
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants