Boost logo

Boost :

Subject: Re: [boost] [filesystem] temp_directory_path() behavior on Windows
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-02-03 07:12:59


On 3 Feb 2015 at 6:32, Beman Dawes wrote:

> > Given that there is a C:\Windows\Temp directory (and it gets recreated by
> > Windows if you delete it even if you divert the system TEMP and TMP env.
> > variables to a different directory) the documentation 'probably' meant "The
> > Windows\Temp directory" not the Windows directory itself...
>
> Interesting. Makes sense.
>
> The Windows directory can be determined by GetSystemWindowsDirectoryW,
> so that means no dependency at all on the state of environmental
> variables.

Corporate installs will often set USERPROFILE to a LAN samba share
and TMP/TEMP to a local ramdisk or directory cleared on logout.
C:\Windows will be completely read only.

There is also the use case under Terminal Services where there are
two Windows directories, GetWindowsDirectory and
GetSystemWindowsDirectory.

You also can't assume that any environment variables are set. If
you're running as a system service you may have a blank environment
and no user profile/home directory. Also, any of the Windows shell
function SHxxx() will fail in this use case.

For reference, when AFIO gains temporary file dispatchers in v1.4, I
was going to use the following schema as I cannot use GetTempPath
(AFIO exclusively uses extended NT kernel paths and cannot use the
260 length win32 ones):

1. %TMP%

2. %TEMP%

3. %LOCALAPPDATA%\Temp

4. %USERPROFILE%\Temp

5. %HOME%\Temp

6. %ALLUSERSPROFILE%\Temp

7. %SystemRoot%\Temp

8. GetWindowsDirectory()\Temp

9. %SystemDrive%\Users\Public\Temp

It would have to be a very borked situation if one of those didn't
work.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk