diff options
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 2c916e5..dd0c33a 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -21,6 +21,14 @@ #include "cmSystemTools.h" #include "cmTarget.h" +#include <cmsys/auto_ptr.hxx> + +//---------------------------------------------------------------------------- +cmExportFileGenerator::cmExportFileGenerator() +{ + this->AppendMode = false; +} + //---------------------------------------------------------------------------- void cmExportFileGenerator::AddConfiguration(const char* config) { @@ -43,8 +51,23 @@ void cmExportFileGenerator::SetExportFile(const char* mainFile) bool cmExportFileGenerator::GenerateImportFile() { // Open the output file to generate it. - cmGeneratedFileStream exportFileStream(this->MainImportFile.c_str(), true); - if(!exportFileStream) + cmsys::auto_ptr<std::ofstream> foutPtr; + if(this->AppendMode) + { + // Open for append. + cmsys::auto_ptr<std::ofstream> + ap(new std::ofstream(this->MainImportFile.c_str(), std::ios::app)); + foutPtr = ap; + } + else + { + // Generate atomically and with copy-if-different. + cmsys::auto_ptr<cmGeneratedFileStream> + ap(new cmGeneratedFileStream(this->MainImportFile.c_str(), true)); + ap->SetCopyIfDifferent(true); + foutPtr = ap; + } + if(!foutPtr.get() || !*foutPtr) { std::string se = cmSystemTools::GetLastSystemError(); cmOStringStream e; @@ -53,7 +76,7 @@ bool cmExportFileGenerator::GenerateImportFile() cmSystemTools::Error(e.str().c_str()); return false; } - std::ostream& os = exportFileStream; + std::ostream& os = *foutPtr; // Start with the import file header. this->GenerateImportHeaderCode(os); |