]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Wed, 26 Mar 2008 08:51:43 +0000 (08:51 +0000)
committerguigues <guigues>
Wed, 26 Mar 2008 08:51:43 +0000 (08:51 +0000)
kernel/src/bbtkInterpreter.cxx
packages/wx/bbs/boxes/bbDoubleSlider.bbs

index e4d872b48847931b92969197fafa8b179462c350..ab0075d2e84030d01bd0ac1bd3c5a16b0adf3d46 100644 (file)
@@ -3,8 +3,8 @@
   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
@@ -973,7 +973,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
     std::string upath;
     pkgname = Utilities::ExtractScriptName(name,upath);
 
-    bbtkMessage("Interpreter",1,
+    bbtkMessage("Interpreter",3,
                "extract : pkgname [" << pkgname
                 << "] upath [" << upath << "]" << std::endl);
     bool fullnameGiven = false; 
@@ -997,7 +997,14 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
        // ==== 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
@@ -1009,102 +1016,67 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
                  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);
              }
            
index b6278069209688d83ac30d37b2cacce284a54b7f..8afcc161d41b413789fe7f0adbeaac4f09d68316 100644 (file)
@@ -1,3 +1,5 @@
+load wx
+
 define DoubleSlider wx
  description "test object"
  category "widget"