mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-21 23:00:50 +08:00
cmGeneratedFileStream: Use random temporary file extension by default
Avoid collisions with project-specified files named with `.tmp`. Issue: #20873
This commit is contained in:
@@ -129,7 +129,9 @@ void cmGeneratedFileStreamBase::Open(std::string const& name)
|
|||||||
if (!this->TempExt.empty()) {
|
if (!this->TempExt.empty()) {
|
||||||
this->TempName += this->TempExt;
|
this->TempName += this->TempExt;
|
||||||
} else {
|
} else {
|
||||||
this->TempName += "tmp";
|
char buf[64];
|
||||||
|
sprintf(buf, "tmp%05x", cmSystemTools::RandomSeed() & 0xFFFFF);
|
||||||
|
this->TempName += buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the temporary file that will be used is not present.
|
// Make sure the temporary file that will be used is not present.
|
||||||
|
Reference in New Issue
Block a user