diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-02-23 00:24:43 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-02-23 00:24:43 (GMT) |
commit | 0b0d1b1d436c6e59ed9ea5c25e1f454fc0ae7827 (patch) | |
tree | ed4c5e1e8bc331799cba8c2a797de8228f9f1f97 /Source/cmConfigureFileNoAutoconf.cxx | |
parent | 5d903c6b0f5622a149e0aeda1053ce82b39d2807 (diff) | |
download | CMake-0b0d1b1d436c6e59ed9ea5c25e1f454fc0ae7827.zip CMake-0b0d1b1d436c6e59ed9ea5c25e1f454fc0ae7827.tar.gz CMake-0b0d1b1d436c6e59ed9ea5c25e1f454fc0ae7827.tar.bz2 |
ENH: add CMakeCache.txt support
Diffstat (limited to 'Source/cmConfigureFileNoAutoconf.cxx')
-rw-r--r-- | Source/cmConfigureFileNoAutoconf.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/cmConfigureFileNoAutoconf.cxx b/Source/cmConfigureFileNoAutoconf.cxx index 4d60e81..270c4fb 100644 --- a/Source/cmConfigureFileNoAutoconf.cxx +++ b/Source/cmConfigureFileNoAutoconf.cxx @@ -49,11 +49,13 @@ void cmConfigureFileNoAutoconf::FinalPass() std::string path = m_OuputFile.substr(0, pos); cmSystemTools::MakeDirectory(path.c_str()); } - std::ofstream fout(m_OuputFile.c_str()); + std::string tempOutputFile = m_OuputFile; + tempOutputFile += ".tmp"; + std::ofstream fout(tempOutputFile.c_str()); if(!fout) { cmSystemTools::Error("Could not open file for write in copy operatation", - m_OuputFile.c_str()); + tempOutputFile.c_str()); return; } // now copy input to output and expand varibles in the @@ -64,10 +66,19 @@ void cmConfigureFileNoAutoconf::FinalPass() while(fin) { fin.getline(buffer, bufSize); - inLine = buffer; - m_Makefile->ExpandVariablesInString(inLine); - fout << inLine << "\n"; + if(fin) + { + inLine = buffer; + m_Makefile->ExpandVariablesInString(inLine); + fout << inLine << "\n"; + } } + // close the files before attempting to copy + fin.close(); + fout.close(); + cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), + m_OuputFile.c_str()); + cmSystemTools::RemoveFile(tempOutputFile.c_str()); #endif } |