Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/03/26 08:27:19 $
- Version: $Revision: 1.55 $
+ Date: $Date: 2008/03/26 08:51:43 $
+ Version: $Revision: 1.56 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::string upath;
pkgname = Utilities::ExtractScriptName(name,upath);
- bbtkMessage("Interpreter",1,
+ bbtkMessage("Interpreter",3,
"extract : pkgname [" << pkgname
<< "] upath [" << upath << "]" << std::endl);
bool fullnameGiven = false;
// ==== absolute path provided
else if (upath[0]=='/' || upath[1] == ':' )
{
- script_paths.push_back(upath);
+ if ( Utilities::IsDirectory( upath ) )
+ {
+ script_paths.push_back(upath);
+ }
+ else
+ {
+ bbtkError("'"<<upath<<"' : not a valid folder");
+ }
}
// ==== relative path provided : search all bbs path appended with
// the relative path provided
i++)
{
std::string full_path(*i);
+ // we *really* want '.' to be the current working directory
+ if (full_path == ".") {
+ char buf[2048]; // for getcwd
+ char * currentDir = getcwd(buf, 2048);
+ std::string cwd(currentDir);
+ full_path = currentDir;
+ } // if full_path
+
full_path += ConfigurationFile::GetInstance().Get_file_separator();
full_path += upath;
- script_paths.push_back(full_path);
- }
- }
+
+ if ( Utilities::IsDirectory( full_path ) )
+ {
+ script_paths.push_back(full_path);
+ }
+ }
+ }
// === search paths list complete : now explore it
- bbtkMessage("Interpreter",1,
- "'*' provided. search paths : " << std::endl);
- /*
- int nbFiles = Utilities::Explore(upath, false, Filenames);
- nbBssFiles = 0;
- for (std::vector<std::string>::iterator i = Filenames.begin();
- i!= Filenames.end(); ++i)
- {
- int lgr = (*i).size();
- if (lgr < 5)
- continue; // ignore non .bbs file
- if ((*i).substr(lgr-4, 4) != ".bbs")
- continue;
- //printf("EED Interpreter::SwitchToFile flag01 %s \n", (*i).c_str() );
- (*stream) << "include \"" << *i << "\"\n";
-
- nbBssFiles++;
- } // for vector
- if (nbBssFiles==0)
- {
- bbtkMessage("Interpreter",2,
- "WARNING : No '.bbs' file found in ["
- << upath << "]" << std::endl);
- }
- else
- {
- SwitchToStream(stream);
- }
- return;
- } // if upath
- */
- std::string path;
+ if (script_paths.empty())
+ {
+ bbtkMessage("Interpreter",1,
+ "'"<<upath<<"' : No matching folder" << std::endl);
+ }
+
+
std::vector<std::string>::iterator i;
- std::string fullDirectoryName;
for (i=script_paths.begin();i!=script_paths.end();i++)// ==== relative name, iterate + load all .bbs files
{
- path = *i;
-
bbtkMessage("Interpreter",1,
- "----> '" << path << "'" << std::endl);
- // we *really* want '.' to be the current working directory
- if (path == ".") {
- char buf[2048]; // for getcwd
- char * currentDir = getcwd(buf, 2048);
- std::string cwd(currentDir);
- path = currentDir;
- } // if path
-
- fullDirectoryName = Utilities::MakePkgnameFromPath(path, upath, false);
-
- // without last slash "\"
- std::string fullDirectoryNameClean = fullDirectoryName.substr(0,fullDirectoryName.size()-1);
-
- // Check if directory exists
- if ( ! Utilities::IsDirectory( fullDirectoryNameClean ) )
- {
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkMessage("Interpreter",1," [" <<fullDirectoryName
- <<"] : doesn't exist" <<std::endl);
- continue; // try next path
- } // if IsDirectory
- foundFile = true;
+ "--> Looking in '" << *i << "'" << std::endl);
+
Filenames.clear();
- int nbFiles = Utilities::Explore(fullDirectoryName, false, Filenames);
+ int nbFiles = Utilities::Explore(*i, false, Filenames);
nbBssFiles = 0;
- for (std::vector<std::string>::iterator i = Filenames.begin(); i!= Filenames.end(); ++i)
+ for (std::vector<std::string>::iterator j = Filenames.begin();
+ j!= Filenames.end(); ++j)
{
- int lgr = (*i).size();
+ int lgr = (*j).size();
if (lgr < 5)
continue; // ignore non .bbs file
- if ((*i).substr(lgr-4, 4) != ".bbs")
+ if ((*j).substr(lgr-4, 4) != ".bbs")
continue;
- // printf("EED Interpreter::SwitchToFile flag02 %s \n", (*i).c_str() );
- (*stream) << "include \"" << *i << "\"\n";
+ (*stream) << "include \"" << *j << "\"\n";
+ bbtkMessage("Interpreter",2,
+ " --> Found '" << *j << "'" << std::endl);
nbBssFiles++;
} // for vector
+
if (nbBssFiles==0)
{
bbtkMessage("Interpreter",1,
- "WARNING : No '.bbs' file found in ["
- << fullDirectoryName << "]" << std::endl);
+ " --> No .bbs found"<< std::endl);
}
else
{
+ bbtkMessage("Interpreter",1,
+ " --> "<<nbBssFiles<<" .bbs found"<< std::endl);
SwitchToStream(stream);
}