Fix createUniqueFile() to do what it is documented to do: create the unique file in a temporary directory if the model isn't absolute. Fix the callers of createUniqueFile() which were affected by this change. Add test cases to verify patch.
I'm not sure about the change. I think both cases (creating a file in the current and in the system temp directory) should be supported.
The example in createUniqueFile() docs should be updated too.
You need to use path::append here. A path returned by system_temp_directory() never has trailing separator.
Well, the current interface for createUniqueFile() doesn't allow me to select current or temp directory behavior. Are you proposing that I change it?
Because if you wanted to create a file in the current directory, you could just use fs::make_absolute() and pass it relative path. That's what I did for all the clients of createUniqueFile() who wanted a file in the current directory.
What do you mean by "the example in createUniqueFile() docs should be updated too"?
Strange. On my system (OS X) system_temp_directory() has a trailing separator. But I can see why I might not be able to rely on that on all platforms. I've updated the test case to use append.
About the example. Currently it is:
clang-%%-%%-%%-%%-%%.s => clang-a0-b1-c2-d3-e4.s.
With your changes it should be something like:
clang-%%-%%-%%-%%-%%.s => /tmp/clang-a0-b1-c2-d3-e4.s.
In general we have 3 options here:
- Leave the implementation as it was, fix the docs. There are definitely use cases (exposed by your patch) that would benefit from that.
- Apply your patch. I suspect it is the case you are interested in.
- Try to support 1 and 2. It can be by adding additional param to the function or by adding similar function.
I'm not sure which solution is the best so I would like someone else to comment on that.
I was quite sure the docs of system_temp_directory() stated that it would not have the trailing /. I will look at that later, but I cannot test OSX myself.
I would say having the trailing dir separator is at least not guaranteed.