BUG#675: If not appending, do copy-if-different on exported file.

This commit is contained in:
Brad King 2004-03-15 10:44:53 -05:00
parent bf9dce6eb9
commit 7b6491d36b
1 changed files with 13 additions and 6 deletions

View File

@ -17,6 +17,7 @@
#include "cmExportLibraryDependencies.h" #include "cmExportLibraryDependencies.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmGeneratedFileStream.h"
#include "cmake.h" #include "cmake.h"
// cmExecutableCommand // cmExecutableCommand
@ -49,7 +50,7 @@ void cmExportLibraryDependenciesCommand::FinalPass()
} }
// Create a full path filename for output Testfile // Create a full path filename for output
std::string fname = m_Args[0]; std::string fname = m_Args[0];
bool append = false; bool append = false;
if(m_Args.size() > 1) if(m_Args.size() > 1)
@ -59,16 +60,23 @@ void cmExportLibraryDependenciesCommand::FinalPass()
append = true; append = true;
} }
} }
// Open the output Testfile
std::ofstream fout; // Use copy-if-different if not appending.
std::ostream* foutPtr;
std::auto_ptr<cmGeneratedFileStream> foutNew;
if(append) if(append)
{ {
fout.open(fname.c_str(), std::ios::app); foutPtr = new std::ofstream(fname.c_str(), std::ios::app);
} }
else else
{ {
fout.open(fname.c_str()); std::auto_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(fname.c_str()));
foutNew = ap;
foutPtr = &foutNew->GetStream();
} }
std::ostream& fout = *foutPtr;
if (!fout) if (!fout)
{ {
cmSystemTools::Error("Error Writing ", fname.c_str()); cmSystemTools::Error("Error Writing ", fname.c_str());
@ -116,6 +124,5 @@ void cmExportLibraryDependenciesCommand::FinalPass()
} }
} }
} }
fout.close();
return; return;
} }