diff --git a/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus.cpp b/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus.cpp index e18ba097abc1a8b5fe402fb81c2991a80e8b9052..df9b49bc9b6139ba8b048736aeaa21109bf6c2d4 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus.cpp @@ -122,6 +122,8 @@ int LoadEventPreNexus::confidence(Kernel::FileDescriptor & descriptor) const // If this looks like a binary file where the exact file length is a multiple // of the DasEvent struct then we're probably okay. + if(descriptor.isAscii()) return 0; + const size_t objSize = sizeof(DasEvent); auto &handle = descriptor.data(); // get the size of the file in bytes and reset the handle back to the beginning @@ -129,7 +131,7 @@ int LoadEventPreNexus::confidence(Kernel::FileDescriptor & descriptor) const const size_t filesize = static_cast<size_t>(handle.tellg()); handle.seekg(0, std::ios::beg); - if (filesize % objSize != 0) return 80; + if (filesize % objSize == 0) return 80; else return 0; } diff --git a/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus2.cpp index ea1cd74114a94c144e62536e574ab39a4a9a9519..eab4b22326610d3ee929911ca1f418a21b5b2728 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -199,6 +199,8 @@ int LoadEventPreNexus2::confidence(Kernel::FileDescriptor & descriptor) const // If this looks like a binary file where the exact file length is a multiple // of the DasEvent struct then we're probably okay. + if(descriptor.isAscii()) return 0; + const size_t objSize = sizeof(DasEvent); auto &handle = descriptor.data(); // get the size of the file in bytes and reset the handle back to the beginning @@ -206,7 +208,7 @@ int LoadEventPreNexus2::confidence(Kernel::FileDescriptor & descriptor) const const size_t filesize = static_cast<size_t>(handle.tellg()); handle.seekg(0, std::ios::beg); - if (filesize % objSize != 0) return 80; + if (filesize % objSize == 0) return 80; else return 0; } diff --git a/Code/Mantid/Framework/DataHandling/src/LoadRKH.cpp b/Code/Mantid/Framework/DataHandling/src/LoadRKH.cpp index a28ae7660dba7e1a636367c6a032197d9bec1b37..a9fab668bc4da85a51c2e002ea796d8a01bbc091 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadRKH.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadRKH.cpp @@ -43,9 +43,6 @@ int LoadRKH::confidence(Kernel::FileDescriptor & descriptor) const { if(!descriptor.isAscii()) return 0; - typedef boost::tokenizer<boost::char_separator<char> > tokenizer; - boost::char_separator<char> sep(" "); - auto &file = descriptor.data(); std::string fileline(""); @@ -54,15 +51,16 @@ int LoadRKH::confidence(Kernel::FileDescriptor & descriptor) const // -- First line -- std::getline(file, fileline); - // LOQ or SANS2D - if(fileline.find("LOQ") == std::string::npos && fileline.find("SANS2D") == std::string::npos) return 0; + // LOQ or SANS2D (case insensitive) + if(boost::ifind_first(fileline, "loq").empty() && boost::ifind_first(fileline, "sans2d").empty()) return 0; + // Next should be date time string static const char* MONTHS[12] = {"-JAN-", "-FEB-", "-MAR-", "-APR-", "-MAY-", "-JUN-", "-JUL-", "-AUG-", "-SEP-", "-OCT-", "-NOV-", "-DEC-"}; bool foundMonth(false); for(size_t i = 0 ; i < 12; ++i) { - if(fileline.find(MONTHS[i]) != std::string::npos) + if(!boost::ifind_first(fileline, MONTHS[i]).empty()) { foundMonth = true; break; @@ -73,13 +71,13 @@ int LoadRKH::confidence(Kernel::FileDescriptor & descriptor) const // there are no constraints on the second line std::getline(file, fileline); - // read 3rd line - should contain sequence " 0 0 0 1" + // read 3rd line - should contain sequence "0 0 0 1" std::getline(file, fileline); - if(fileline.find(" 0 0 0 1") == std::string::npos) return 0; + if(fileline.find("0 0 0 1") == std::string::npos) return 0; - // read 4th line - should contain sequence " 0 0 0 1" + // read 4th line - should contain sequence ""0 0 0 0" std::getline(file, fileline); - if(fileline.find(" 0 0 0 0") == std::string::npos) return 0; + if(fileline.find("0 0 0 0") == std::string::npos) return 0; // read 5th line - should contain sequence "3 (F12.5,2E16.6)" std::getline(file, fileline);