From d360f72a31b8dad577b29bddaa851b756751715d Mon Sep 17 00:00:00 2001 From: Karl Palmen <karl.palmen@stfc.ac.uk> Date: Mon, 19 Mar 2012 14:09:17 +0000 Subject: [PATCH] Get instrument from file name by searching up to "_Def" re #3971 This time using the string.find("_Def") function, which does look for the argument string as a substring rather than any character in the argument string. Also modified a unit test to expect "REF_L" rather than "REF" . Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk> --- Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp | 2 +- Code/Mantid/Framework/DataHandling/test/LoadTOFRawNexusTest.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp b/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp index c3ec47cea7b..58d51fbd9d9 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp @@ -134,7 +134,7 @@ namespace Mantid const std::string::size_type stripPath = m_filename.find_last_of("\\/"); std::string instrumentFile = m_filename.substr(stripPath+1,m_filename.size()); // Strip off "_Definition.xml" - m_instName = instrumentFile.substr(0,instrumentFile.find_first_of("_")); + m_instName = instrumentFile.substr(0,instrumentFile.find("_Def")); } // Load the XML text into a string diff --git a/Code/Mantid/Framework/DataHandling/test/LoadTOFRawNexusTest.h b/Code/Mantid/Framework/DataHandling/test/LoadTOFRawNexusTest.h index 105a3fb786e..9753acbeb63 100644 --- a/Code/Mantid/Framework/DataHandling/test/LoadTOFRawNexusTest.h +++ b/Code/Mantid/Framework/DataHandling/test/LoadTOFRawNexusTest.h @@ -58,7 +58,7 @@ public: ); TS_ASSERT(ws); if (!ws) return; TS_ASSERT_EQUALS(ws->blocksize(), 501); - TS_ASSERT_EQUALS(ws->getInstrument()->getName(), "REF"); + TS_ASSERT_EQUALS(ws->getInstrument()->getName(), "REF_L"); TS_ASSERT_EQUALS(ws->getNumberHistograms(), 77824); ISpectrum * spec = ws->getSpectrum(27955); -- GitLab