Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Path.home on Windows #11503

Merged

Conversation

HertzDevil
Copy link
Contributor

Path.home uses the %HOME% environment variable even on Windows, where it is nonstandard. This PR changes it to %USERPROFILE% and adds a fallback when that environment variable is absent.

@HertzDevil HertzDevil added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system labels Nov 27, 2021
@HertzDevil
Copy link
Contributor Author

HertzDevil commented Nov 27, 2021

The corresponding fallback for POSIX is a combination of getpwuid_r with either getuid or geteuid. The latter doesn't exist in the LibC bindings yet, and also I'm not sure if the distinction between real and effective user exists on Windows. For ease of review I am doing that in a later PR.

src/crystal/system/win32/path.cr Outdated Show resolved Hide resolved
spec/std/file_spec.cr Show resolved Hide resolved
@straight-shoota straight-shoota added this to the 1.3.0 milestone Dec 4, 2021
@straight-shoota straight-shoota merged commit 8f14cf0 into crystal-lang:master Dec 6, 2021
@HertzDevil HertzDevil deleted the feature/windows-path-home branch December 6, 2021 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants