Newer
Older
Gigg, Martyn Anthony
committed
//set worksapce data
setWorkspaceData(ws_sptr, timeChannelsVec, wsIndex, i,noTimeRegimes,lengthIn,1);
++wsIndex;
if (numberOfPeriods == 1)
{
if (++histCurrent % 100 == 0)
{
m_prog = double(histCurrent) / histTotal;
}
interruption_point();
}
}
else
{
skipData(file, histToRead);
}
Gigg, Martyn Anthony
committed
}
}
Sofia Antony
committed
Sofia Antony
committed
Gigg, Martyn Anthony
committed
/**
* Check if the buffer looks like a RAW file header by looking at
* at the "address of RUN and INST section" attribute - if there, it's an ISIS raw file.
* @param nread The number of bytes in the buffer
* @param buffer A buffer of nread bytes of the file
* @returns True if this looks like an ISIS raw file
*/
bool LoadRawHelper::isRawFileHeader(const int nread, const unsigned char* buffer) const
{
if( nread > 88 && (buffer[84] == 32) && (buffer[88] == 126) )
{
return true;
}
else return false;
}
Sofia Antony
committed
Gigg, Martyn Anthony
committed
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
/**This method does a quick file check by checking the no.of bytes read nread params and header buffer
* @param filePath- path of the file including name.
* @param nread :: no.of bytes read
* @param header :: The first 100 bytes of the file as a union
* @return true if the given file is of type which can be loaded by this algorithm
*/
bool LoadRawHelper::quickFileCheck(const std::string& filePath,size_t nread,const file_header& header)
{
std::string extn=extension(filePath);
bool braw = (!extn.compare("raw")||!extn.compare("add")||extn[0]=='s') ? true : false;
if( isRawFileHeader(nread, header.full_hdr) || braw )
{
return true;
}
else
{
return false;
}
}
/**Checks the file by opening it and reading few lines
* @param filePath :: name of the file inluding its path
* @return an integer value how much this algorithm can load the file
*/
int LoadRawHelper::fileCheck(const std::string& filePath)
{
/* Open the file and read in the first bufferSize bytes - these will
* be used to determine the type of the file
*/
int bret=0;
FILE* fp = fopen(filePath.c_str(), "rb");
if (fp == NULL)
{
return bret;
}
file_header header;
int nread = fread(&header,sizeof(unsigned char), IDataFileChecker::g_hdr_bytes, fp);
header.full_hdr[IDataFileChecker::g_hdr_bytes] = '\0';
if (nread == -1)
{
fclose(fp);
return bret;
}
Sofia Antony
committed
Gigg, Martyn Anthony
committed
if (fclose(fp) != 0)
{
}
if( isRawFileHeader(nread, header.full_hdr) )
{
bret=80;
}
return bret;
}
Sofia Antony
committed
Sofia Antony
committed
Gigg, Martyn Anthony
committed
} // namespace DataHandling
Russell Taylor
committed
} // namespace Mantid