[PATCH] D14320: 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.

Cameron Esfahani via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 17:13:06 PST 2015


dirty added a comment.

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"?


================
Comment at: unittests/Support/Path.cpp:509
@@ +508,3 @@
+  // path should still be absolute.
+  Twine absolutePath = Twine(TDir, "unique%%%%%%.txt");
+  ASSERT_NO_ERROR(fs::createUniqueFile(absolutePath, UniquePath));
----------------
chfast wrote:
> You need to use path::append here. A path returned by system_temp_directory() never has trailing separator.
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.


http://reviews.llvm.org/D14320





More information about the llvm-commits mailing list