On 4 Feb 2015 at 16:16, Gavin Lambert wrote:
I think it's faster to iterate all ten in that order actually. The big problem with caching results is that if your temp drive is on a network share, it can come and go over the lifetime of your process.
In the end, temp files are slow on Windows, as is opening file handles at all actually. That's because on NT you were never supposed to use temp files when you have a NT kernel namespace to use (i.e. named section objects). Unfortunately, those don't play well without a bit of work with iostreams, fopen et al.
I don't understand your response given what I wrote. I meant that those options would be tried in order to see if they resolve to a valid directory the caller has permissions to use and, if not, try the next.
Don't you have to touch the filesystem to do that? I can imagine many cases where user code might want to obtain the path in contexts where they don't want to hit the filesystem at all (which is why the WinAPI call does not perform that check).
The context that wants to obtain the path is not necessarily the one that wants to make use of it.
Yep, Gavin has nailed my very poor original explanation (it was like 1am when I wrote it, and I have been burning the candle at both ends for two weeks now as I try to push out a library release which seems to have a never ending tail of small release quality issues). I had thought you were recommending an ACL lookup for path viability. No I meant that temp_directory_path() basically needs to iterate those options I listed. If the given environment variable does not expand to a valid path (note no FS operations needed here), we move to the next option. We don't check for feasibility. For the function which creates temp files for you, it may be useful to know what I'll be doing there. AFIO won't provide any facility for knowing about paths of temp files until after you have created one. Instead you get a dispatcher implementation which creates either anonymous temp files or named temp files at some one of many unknown locations until after file creation (the unknown locations which can be chosen from is user suppliable, so I guess if you supply a single option you get some control), plus you can request "fast moveability" to another given path i.e. that the temp file location be chosen to be on the same volume as the path supplied where possible, thus ensuring that mv works quickly. I just added the support code for that via the new statfs() call in AFIO v1.3 which might ship this week or next week. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/