From 585b94d58cd740b6925cc7273e9c945fa2a16db8 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Wed, 16 Jul 2014 13:51:38 +0100 Subject: [PATCH] Add append option to SaveAscii. Refs #9144 --- Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp b/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp index 9b87eda6bd39..ae939e688ad6 100644 --- a/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp @@ -78,6 +78,8 @@ namespace Mantid declareProperty("ColumnHeader", true, "If true, put column headers into file. "); + declareProperty("AppendToFile", false, "If true, don't overwrite the file. Append to the end of it. "); + } /** @@ -98,6 +100,7 @@ namespace Mantid int spec_min = getProperty("WorkspaceIndexMin"); int spec_max = getProperty("WorkspaceIndexMax"); bool writeHeader = getProperty("ColumnHeader"); + bool appendToFile = getProperty("AppendToFile"); // Check whether we need to write the fourth column m_writeDX = getProperty("WriteXError"); @@ -177,7 +180,7 @@ namespace Mantid throw std::runtime_error("Trying to save an empty workspace"); } std::string filename = getProperty("Filename"); - std::ofstream file(filename.c_str()); + std::ofstream file(filename.c_str(), (appendToFile ? std::ios::app : std::ios::out)); if (!file) {