Skip to content

Commit

Permalink
Refs #9550 - Fully support SANS2D in FileFinder.
Browse files Browse the repository at this point in the history
Covered this edge case with a unit test.  Added a comment to discourage
further extensions to this hack.
  • Loading branch information
PeterParker committed May 30, 2014
1 parent a4636d8 commit efbec8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Code/Mantid/Framework/API/src/FileFinder.cpp
Expand Up @@ -206,6 +206,15 @@ namespace Mantid
{
instrName = "PG3";
}
// We're extending this nasty hack to accomodate data archive searching for SANS2D.
// While this certainly shouldn't be considered good practice, #7515 exists to
// completely redesign FileFinder -- this quick fix will have to do until all this
// code gets an overhaul as part of that ticket. Please think twice before adding
// any more instruments to this list.
else if ((instrName.find("SANS2D") == 0) || (instrName.find("sans2d") == 0))
{
instrName = "SANS2D";
}
else
{
// go forwards looking for the run number to start
Expand Down Expand Up @@ -269,6 +278,12 @@ namespace Mantid
instrPart = "PG3";
nChars = instrPart.length();
}
// Another nasty check for SANS2D. Will do until FileFinder redesign.
else if (boost::algorithm::istarts_with(hint, "SANS2D"))
{
instrPart = "SANS2D";
nChars = instrPart.length();
}
else
{
instrPart = hint.substr(0, nChars);
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/API/test/FileFinderTest.h
Expand Up @@ -63,6 +63,10 @@ class FileFinderTest: public CxxTest::TestSuite
" <zeropadding size=\"8\"/>"
" <technique>Reflectometer</technique>"
" </instrument>"
" <instrument name=\"SANS2D\">"
" <zeropadding size=\"8\"/>"
" <technique>Small Angle Scattering</technique>"
" </instrument>"
" </facility>"
" <facility name=\"SNS\" delimiter=\"_\" FileExtensions=\"_event.nxs,.nxs,.dat\">"
" <archive>"
Expand Down Expand Up @@ -175,6 +179,7 @@ class FileFinderTest: public CxxTest::TestSuite
TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("REF_L_1234.nxs.h5").name(), "REF_L");
TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("LOQ16613.n001").name(), "LOQ");
TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("LOQ16613.s01").name(), "LOQ");
TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("SANS2D00032676.nxs").name(), "SANS2D");
}

void testGetExtension()
Expand Down

0 comments on commit efbec8d

Please sign in to comment.