Add a createUniqueFile function and switch llvm's users of unique_file.

This function is complementary to createTemporaryFile. It handles the case were
the unique file is *not* temporary: we will rename it in the end. Since we
will rename it, the file has to be in the same filesystem as the final
destination and we don't prepend the system temporary directory.

This has a small semantic difference from unique_file: the default mode is 0666.
This matches the behavior of most unix tools. For example, with this change
lld now produces files with the same permissions as ld. I will add a test
of this change when I port clang over to createUniqueFile (next commit).

llvm-svn: 185726
This commit is contained in:
Rafael Espindola
2013-07-05 21:01:08 +00:00
parent 1035790034
commit c9d2e5b8ca
9 changed files with 60 additions and 21 deletions

View File

@@ -78,10 +78,9 @@ LockFileManager::LockFileManager(StringRef FileName)
UniqueLockFileName += "-%%%%%%%%";
int UniqueLockFileID;
if (error_code EC
= sys::fs::unique_file(UniqueLockFileName.str(),
UniqueLockFileID,
UniqueLockFileName,
/*makeAbsolute=*/false)) {
= sys::fs::createUniqueFile(UniqueLockFileName.str(),
UniqueLockFileID,
UniqueLockFileName)) {
Error = EC;
return;
}