Subject: Re: [boost] [filesystem] temp_directory_path() behavior on Windows
From: Beman Dawes (bdawes_at_[hidden])
Date: 2015-02-02 07:26:04
On Sun, Feb 1, 2015 at 7:53 PM, Rob Stewart <rob.stewart_at_[hidden]> wrote:
> On January 31, 2015 11:29:38 AM EST, Peter Dimov <lists_at_[hidden]> wrote:
>> Beman Dawes wrote:
>> > The suggested fix is to use GetEnvironmentVariable to in effect
>> > GetTempPath() the way we would like it to work.
>> Not that the documented behavior of GetTempPath makes any sense to me
>> - the
>> default temp directory is at %LOCALAPPDATA%\Temp since Win95 or so -
>> but the
>> suggested fix is actually:
>> "A workaround is to first try to use GetEnvironmentVariable on "TMP"
>> "TEMP", then fall back on GetTempPath."
> You'll have to compare the strings before and after calling GetEnvironmentVariable(). It doesn't indicate whether any substitutions were made and the result could be the same length as the original.
I'm not actually going to fall back to GetTempPath. My tentative
implementation using only GetEnvironmentVariable() is much cleaner.
See below for the proposed list of env variables.
>> So, if implemented, it makes
>> > OTOH, excluding the Windows directory is a breaking change for
>> > currently depending on that behavior, so I thought it best to ask
>> > comments before charging ahead.
>> a non-issue, unless you want to avoid calling GetTempPath entirely, in
>> case I would return %LOCALAPPDATA%\Temp at step 3, obtained via
SHGetFolderPath is deprecated, and in any case it is very simple and
clean just to use a list of directories with
My current implementation uses this list (shown with the defaults for
clean Win 7 and Win 10 installs:
Per Peter's suggestion, inserting %LOCALAPPDATA%\Temp would make
historic sense. I'm mildly in favor of that.
There are two other default environmental variables we could use:
and there are also API functions GetWindowsDirectory and
GetSystemWindowsDirectory, but their use is "primarily for
compatibility with legacy applications". But I'm against using the
Windows directory, however obtained.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk