mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 15:32:10 +08:00
cmGeneratedFileStream: Optionally use custom temporary file extension
This commit is contained in:
@@ -122,10 +122,15 @@ void cmGeneratedFileStreamBase::Open(std::string const& name)
|
|||||||
// Create the name of the temporary file.
|
// Create the name of the temporary file.
|
||||||
this->TempName = name;
|
this->TempName = name;
|
||||||
#if defined(__VMS)
|
#if defined(__VMS)
|
||||||
this->TempName += "_tmp";
|
this->TempName += "_";
|
||||||
#else
|
#else
|
||||||
this->TempName += ".tmp";
|
this->TempName += ".";
|
||||||
#endif
|
#endif
|
||||||
|
if (!this->TempExt.empty()) {
|
||||||
|
this->TempName += this->TempExt;
|
||||||
|
} else {
|
||||||
|
this->TempName += "tmp";
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the temporary file that will be used is not present.
|
// Make sure the temporary file that will be used is not present.
|
||||||
cmSystemTools::RemoveFile(this->TempName);
|
cmSystemTools::RemoveFile(this->TempName);
|
||||||
@@ -216,3 +221,8 @@ void cmGeneratedFileStream::SetName(const std::string& fname)
|
|||||||
{
|
{
|
||||||
this->Name = fname;
|
this->Name = fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmGeneratedFileStream::SetTempExt(std::string const& ext)
|
||||||
|
{
|
||||||
|
this->TempExt = ext;
|
||||||
|
}
|
||||||
|
@@ -43,6 +43,9 @@ protected:
|
|||||||
// The name of the final destination file for the output.
|
// The name of the final destination file for the output.
|
||||||
std::string Name;
|
std::string Name;
|
||||||
|
|
||||||
|
// The extension of the temporary file.
|
||||||
|
std::string TempExt;
|
||||||
|
|
||||||
// The name of the temporary file.
|
// The name of the temporary file.
|
||||||
std::string TempName;
|
std::string TempName;
|
||||||
|
|
||||||
@@ -138,6 +141,12 @@ public:
|
|||||||
* the output file to be changed during the use of cmGeneratedFileStream.
|
* the output file to be changed during the use of cmGeneratedFileStream.
|
||||||
*/
|
*/
|
||||||
void SetName(const std::string& fname);
|
void SetName(const std::string& fname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set set a custom temporary file extension used with 'Open'.
|
||||||
|
* This does not work if the file was opened by the constructor.
|
||||||
|
*/
|
||||||
|
void SetTempExt(std::string const& ext);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user