From efcb43a88fc6f9dafbfdb8d98ed899edbf7ad8c6 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Tue, 10 May 2005 11:11:28 -0400 Subject: ENH: Allow changing of file name --- Source/cmGeneratedFileStream.cxx | 14 +++++++++++++- Source/cmGeneratedFileStream.h | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index d70bc5c..d0f2cc0 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -162,7 +162,8 @@ void cmGeneratedFileStreamBase::Close() // Only consider replacing the destination file if no error // occurred. - if(m_Okay && + if(!m_Name.empty() && + m_Okay && (!m_CopyIfDifferent || cmSystemTools::FilesDiffer(m_TempName.c_str(), resname.c_str()))) { @@ -277,3 +278,14 @@ int cmGeneratedFileStreamBase::RenameFile(const char* oldname, return rename(oldname, newname) == 0; #endif } + +//---------------------------------------------------------------------------- +void cmGeneratedFileStream::SetName(const char* fname) +{ + if ( !fname ) + { + m_Name = ""; + return; + } + m_Name = fname; +} diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 6706164..cb81d1d 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -130,6 +130,12 @@ public: * Set whether compression is done. */ void SetCompression(bool compression); + + /** + * Set name of the file that will hold the actual output. This method allows + * the output file to be changed during the use of cmGeneratedFileStream. + */ + void SetName(const char* fname); }; #if defined(__sgi) && !defined(__GNUC__) -- cgit v0.12