-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Foundation: adjust NSTemporaryDirectory
for Windows
#1940
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
Conversation
@swift-ci please test |
The returned value should really be cached on all platforms, I think... I don’t know what the expected behavior of the function is if the env vars change between calls. @millenomi ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but would definitely like to see the fix for the macOS version of the code as well
@swift-ci please test macOS platform |
Ugh, this is wrong. This changed the semantics for the macOS target, as it would previously fall back to the TMP env var in the truncation case. |
@swift-ci please test |
Foundation/NSPathUtilities.swift
Outdated
_ = GetTempPathW(cchLength + 1, wszPath.baseAddress) | ||
return String(decodingCString: wszPath.baseAddress!, as: UTF16.self) | ||
#else | ||
#if os(macOS) || os(iOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is absolutely where canImport(Darwin)
should go, since the point of this block is to guard from using API that exists in that module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still hate canImport(Darwin)
, but fine. Although, I think that it should be done in #1941 rather than in this change. I'll update that in a little while.
Windows provides `GetTempPath` for getting the temporary directory which consults the environment variables and falls back through a cascading set ultimately ending up at `%SystemRoot%\Temp` if nothing else is found. The last path is not exactly great, but, we do not expect to end up there as modern Windows will use `%UserProfile%\Local Settings` before that.
@swift-ci please test |
1 similar comment
@swift-ci please test |
Windows provides
GetTempPath
for getting the temporary directory whichconsults the environment variables and falls back through a cascading
set ultimately ending up at
%SystemRoot%\Temp
if nothing else isfound. The last path is not exactly great, but, we do not expect to end
up there as modern Windows will use
%UserProfile%\Local Settings
before that.