changed the check for is a file using stat and not looking for a dot in file name

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@117 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-11-26 15:54:22 +00:00
parent 95741a1c33
commit 0b8f6cc925
3 changed files with 64 additions and 48 deletions

View File

@ -129,29 +129,30 @@ void qActionsWidget::SetScriptFile(){
cout << "Setting\taction:" << id << "\tscript:" << fName.toAscii().constData() << endl;
#endif
bool set = false;
struct stat st_buf;
//blank
if(fName.isEmpty()) set = true;
else if(!fName.compare("none")) set = true;
if(fName.isEmpty())
set = true;
else if(!fName.compare("none"))
set = true;
//not blank
else{
QString file = dispScript->text().section('/',-1);
//is a file
if(file.contains('.')){
//check if it exists and set the script file
if(QFile::exists(fName)) set = true;
//if the file doesnt exist, set it to what it was before
else{
//path doesnt exist
if(stat(fName.toAscii().constData(),&st_buf)){
qDefs::Message(qDefs::WARNING,"The script file entered does not exist","ActionsWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}//not a file, set it to what it was before
else {
//if its not a file
else if (!S_ISREG (st_buf.st_mode)) {
qDefs::Message(qDefs::WARNING,"The script file path entered is not a file","ActionsWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
else
set=true;
}
//if blank or valid file
if(set){
//scan and positions wouldnt get here

View File

@ -285,12 +285,24 @@ void qDetectorMain::LoadConfigFile(const string fName){
#ifdef VERBOSE
cout << "Loading config file at start up:" << fName << endl;
#endif
QString file = QString(fName.c_str());//.section('/',-1);
if((file.contains('.'))&&(QFile::exists(file))){
if(myDet->readConfigurationFile(fName)!=slsDetectorDefs::FAIL)
struct stat st_buf;
QString file = QString(fName.c_str());
//path doesnt exist
if(stat(fName.c_str(),&st_buf))
qDefs::Message(qDefs::WARNING,string("<nobr>Start up configuration failed to load. The following file does not exist:</nobr><br><nobr>")+fName,"Main");
//not a file
else if (!S_ISREG (st_buf.st_mode))
qDefs::Message(qDefs::WARNING,string("<nobr>Start up configuration failed to load. The following file is not a recognized file format:</nobr><br><nobr>")+fName,"Main");
//could not load config file
else if(myDet->readConfigurationFile(fName)==slsDetectorDefs::FAIL)
qDefs::Message(qDefs::INFORMATION,"<nobr>The Configuration Parameters have been loaded successfully at start up.</nobr>","Main");
//successful
else
qDefs::Message(qDefs::INFORMATION,"<nobr>The Configuration Parameters have been loaded successfully at start up.</nobr>","Main");
else qDefs::Message(qDefs::WARNING,string("<nobr>Could not load the Configuration Parameters at start up from file:</nobr><br><nobr>")+fName,"Main");
}else qDefs::Message(qDefs::WARNING,string("<nobr>Start up configuration failed to load. The following file does not exist:</nobr><br><nobr>")+fName,"Main");
}

View File

@ -445,11 +445,12 @@ void qScanWidget::SetScriptFile(){
#ifdef VERYVERBOSE
cout << "Entering SetScriptFile()" << endl;
#endif
QString fName = dispScript->text();bool set = false;
QString fName = dispScript->text();
#ifdef VERBOSE
cout << "Setting\tscan:" << id << "\tscript:" << fName.toAscii().constData() << endl;
#endif
bool set = false;
struct stat st_buf;
//blank
if(fName.isEmpty())
@ -466,22 +467,18 @@ void qScanWidget::SetScriptFile(){
}
//not blank and custom script mode
if(!set){
QString file = dispScript->text().section('/',-1);
//is a file
if(file.contains('.')){
//check if it exists and set the script file
if(QFile::exists(fName))
set = true;
//if the file doesnt exist, set it to what it was before
else{
//path doesnt exist
if(stat(fName.toAscii().constData(),&st_buf)){
qDefs::Message(qDefs::WARNING,"The script file entered does not exist","ScanWidget");
dispScript->setText(QString(myDet->getScanScript(id).c_str()));
}
}//not a file, set it to what it was before
else {
//if its not a file
else if (!S_ISREG (st_buf.st_mode)) {
qDefs::Message(qDefs::WARNING,"The script file path entered is not a file","ScanWidget");
dispScript->setText(QString(myDet->getScanScript(id).c_str()));
}
else
set=true;
}
//if blank or valid file
@ -974,8 +971,10 @@ void qScanWidget::SetFileSteps(){
cout << "Setting\tscan:" << id << "\tfile\t:" << fName.toAscii().constData() << endl;
#endif
bool set = false;
struct stat st_buf;
if(fName.isEmpty()){ //blank
//blank
if(fName.isEmpty()){
#ifdef VERBOSE
cout << "Empty file" << endl;
#endif
@ -983,12 +982,13 @@ void qScanWidget::SetFileSteps(){
radioFile->setText("Values from File:*");
QString errTip = fileTip + QString("<br><br><nobr><font color=\"red\">The file path is empty.</font></nobr>");;
radioFile->setToolTip(errTip);dispFile->setToolTip(errTip);btnFile->setToolTip(errTip);
}else{
}
//not a blank
else{
QString file = dispFile->text().section('/',-1);
if(file.contains('.')){ //is a file
//check if it exists and set the script file
if(QFile::exists(fName)) set = true;
else{//if the file doesnt exist, set it to what it was before
//path doesnt exist
if(stat(file.toAscii().constData(),&st_buf)){
#ifdef VERBOSE
cout << "The file entered does not exist." << endl;
#endif
@ -997,7 +997,8 @@ void qScanWidget::SetFileSteps(){
QString errTip = fileTip + QString("<br><br><nobr><font color=\"red\">The file entered does not exist.</font></nobr>");
radioFile->setToolTip(errTip);dispFile->setToolTip(errTip);btnFile->setToolTip(errTip);
}
} else {//not a file, set it to what it was before
//if its not a file
else if (!S_ISREG (st_buf.st_mode)) {
#ifdef VERBOSE
cout << "The file path entered is not a file." << endl;
#endif
@ -1006,6 +1007,8 @@ void qScanWidget::SetFileSteps(){
QString errTip = fileTip + QString("<br><br><nobr><font color=\"red\">The file path entered is not a file.</font></nobr>");
radioFile->setToolTip(errTip); dispFile->setToolTip(errTip);btnFile->setToolTip(errTip);
}
else
set = true;
}
//if valid file