Refined the data-file search

This commit is contained in:
Bastian M. Wojek
2011-06-14 09:42:24 +00:00
parent b448487cd0
commit f0d05d35cd
3 changed files with 68 additions and 38 deletions

View File

@ -19,7 +19,6 @@ FIXED ASCII export from musrview in case of a Fourier-Power- or Fourier-Phase-di
FIXED bug in asymmetry fit with fixed background FIXED bug in asymmetry fit with fixed background
CHANGED the data-file-name handling (MUSR-195). CHANGED the data-file-name handling (MUSR-195).
It is now possible to specify the full file name in the RUN block (including the extension). It is now possible to specify the full file name in the RUN block (including the extension).
The data files that are looked for have to have either full lower-case (e.g. .nxs) or full upper-case (e.g. .NXS) extensions.
CHANGED cosmetics in the musrview legend concerning the units CHANGED cosmetics in the musrview legend concerning the units
CHANGED the user-function dependency from libPMusr to libPUserFcnBase CHANGED the user-function dependency from libPMusr to libPUserFcnBase

View File

@ -574,47 +574,78 @@ Bool_t PRunDataHandler::FileAlreadyRead(TString runName)
* <p> Tests if a file exists (with or without given extension). * <p> Tests if a file exists (with or without given extension).
* The given file-name string will be modified to show the found file name or an empty string if no file is found. * The given file-name string will be modified to show the found file name or an empty string if no file is found.
* *
* \param runName run name to be checked * \param runName run name with full path to be checked
* \param ext extension to be checked * \param ext extension to be checked
*/ */
void PRunDataHandler::TestFileName(TString &runName, TString &ext) void PRunDataHandler::TestFileName(TString &runName, const TString &ext)
{ {
TString tmpStr(runName); TString tmpStr(runName), tmpExt(ext);
// check first if the file exists with a lower-case extension
ext.ToLower(); // check first if the file exists with the default extension which is not given with the run name
runName += TString(".") + ext; runName += TString(".") + ext;
if (gSystem->AccessPathName(runName.Data())!=true) { // found if (gSystem->AccessPathName(runName.Data()) != true) { // found
return; return;
} else { }
runName = tmpStr;
if (tmpStr.EndsWith(ext.Data())) { // assume the lower-case extension is already part of the file name, therefore, do not append it // test if the file exists with only upper-case letters
if (gSystem->AccessPathName(runName.Data())!=true) { // found runName.ToUpper();
return; if (gSystem->AccessPathName(runName.Data()) != true) { // found
} else { // assume a lower-case extension is part of the given file name but the real data file ends with an upper-case extension return;
ext.ToUpper(); }
runName = runName.Replace(static_cast<Ssiz_t>(runName.Length()-ext.Length()), ext.Length(), ext);
if (gSystem->AccessPathName(runName.Data()) != true) { // test if the file exists with only lower-case letters
return; runName.ToLower();
} if (gSystem->AccessPathName(runName.Data()) != true) { // found
} return;
} else { }
ext.ToUpper();
if (tmpStr.EndsWith(ext.Data())) { // assume the upper-case extension is already part of the file name, therefore, do not append it // test if the file exists with the given run name but an only upper-case extension which is not included in the file name
if (gSystem->AccessPathName(runName.Data())!=true) { // found runName = tmpStr;
return; tmpExt.ToUpper();
} else { // assume an upper-case extension is part of the given file name but the real data file ends with a lower-case extension runName += TString(".") + tmpExt;
ext.ToLower(); if (gSystem->AccessPathName(runName.Data()) != true) { // found
runName = runName.Replace(static_cast<Ssiz_t>(runName.Length()-ext.Length()), ext.Length(), ext); return;
if (gSystem->AccessPathName(runName.Data()) != true) { }
return;
} // test if the file exists with the given run name but an only lower-case extension which is not included in the file name
} tmpExt.ToLower();
} else { runName = runName.Replace(static_cast<Ssiz_t>(runName.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt);
runName += TString(".") + ext; // test if the extension is given in upper-case letters and is not included in the file name if (gSystem->AccessPathName(runName.Data()) != true) { // found
if (gSystem->AccessPathName(runName.Data())!=true) { // found return;
return; }
}
} runName = tmpStr;
// the extension is already part of the file name, therefore, do not append it
if (runName.EndsWith(ext.Data(), TString::kIgnoreCase)) {
if (gSystem->AccessPathName(runName.Data()) != true) { // found
return;
}
// assume some extension is part of the given file name but the real data file ends with an lower-case extension
tmpExt.ToLower();
runName = runName.Replace(static_cast<Ssiz_t>(runName.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt);
if (gSystem->AccessPathName(runName.Data()) != true) { // found
return;
}
// assume some extension is part of the given file name but the real data file ends with an upper-case extension
tmpExt.ToUpper();
runName = runName.Replace(static_cast<Ssiz_t>(runName.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt);
if (gSystem->AccessPathName(runName.Data()) != true) { // found
return;
}
// test if the file exists with only lower-case letters and the extension already included in the file name
runName.ToLower();
if (gSystem->AccessPathName(runName.Data()) != true) { // found
return;
}
// test if the file exists with only upper-case letters and the extension already included in the file name
runName.ToUpper();
if (gSystem->AccessPathName(runName.Data()) != true) { // found
return;
} }
} }

View File

@ -67,7 +67,7 @@ class PRunDataHandler
virtual Bool_t ReadFilesMsr(); virtual Bool_t ReadFilesMsr();
virtual Bool_t ReadWriteFilesList(); virtual Bool_t ReadWriteFilesList();
virtual Bool_t FileAlreadyRead(TString runName); virtual Bool_t FileAlreadyRead(TString runName);
virtual void TestFileName(TString &runName, TString &ext); virtual void TestFileName(TString &runName, const TString &ext);
virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx); virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx);
virtual Bool_t FileExistsCheck(const Bool_t fileName, const Int_t idx); virtual Bool_t FileExistsCheck(const Bool_t fileName, const Int_t idx);
virtual Bool_t ReadRootFile(UInt_t tag); virtual Bool_t ReadRootFile(UInt_t tag);