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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/fmanip (Version 11.3.0) and /externals/g4tools/include/tools/fmanip (Version 4.0.p2)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_fmanip                              
  5 #define tools_fmanip                              
  6                                                   
  7 #include "file"                                   
  8 #include "sep"                                    
  9 #include "sout"                                   
 10 #include <ostream>                                
 11                                                   
 12 namespace tools {                                 
 13                                                   
 14 inline bool find_with_dirs(std::ostream& a_out    
 15                            const std::vector<s    
 16                            const std::string&     
 17                            std::string& a_path    
 18                            bool a_verbose = fa    
 19   std::vector<std::string>::const_iterator it;    
 20   for(it=a_dirs.begin();it!=a_dirs.end();++it)    
 21     if((*it).empty()) {                           
 22       // with a "" in dirs, this case could so    
 23       // - a_file in the current directory.       
 24       // - a_file with an absolute path name.     
 25       a_path = a_file; //may be an absolute fi    
 26     } else {                                      
 27       a_path = *it;                               
 28       a_path += sep();                            
 29       a_path += a_file;                           
 30     }                                             
 31                                                   
 32     if(a_verbose) {                               
 33       a_out << "find_with_dirs :"                 
 34             << " look for " << sout(a_path) <<    
 35             << std::endl;                         
 36     }                                             
 37                                                   
 38     if(file::exists(a_path)) {                    
 39       if(a_verbose) {                             
 40         a_out << "find_with_dirs :"               
 41               << " found " << sout(a_path) <<     
 42               << std::endl;                       
 43       }                                           
 44       return true;                                
 45     }                                             
 46   }                                               
 47   a_path.clear();                                 
 48                                                   
 49   if(a_verbose) {                                 
 50     a_out << "find_with_dirs :"                   
 51           << " " << sout(a_file) << " not foun    
 52           << std::endl;                           
 53   }                                               
 54                                                   
 55   return false;                                   
 56 }                                                 
 57                                                   
 58 }                                                 
 59                                                   
 60 #include "get_env"                                
 61                                                   
 62 namespace tools {                                 
 63                                                   
 64 inline bool find_with_env(std::ostream& a_out,    
 65                           const std::string& a    
 66                           const std::string& a    
 67                           std::string& a_path,    
 68                           bool a_verbose = fal    
 69   std::string PATH;                               
 70   if(!get_env(a_env,PATH)) {                      
 71     //look for a a_file in current directory.     
 72     if(file::exists(a_file)) {                    
 73       //a_out << "tools::find_with_env :"         
 74       //      << " env variable " << sout(a_en    
 75       //      << std::endl;                       
 76       a_path = a_file;                            
 77       return true;                                
 78     }                                             
 79     a_out << "tools::find_with_env : env varia    
 80     a_path.clear();                               
 81     return false;                                 
 82   }                                               
 83   if(a_verbose) {                                 
 84     a_out << "find_with_env : env " << sout(a_    
 85   }                                               
 86                                                   
 87   std::vector<std::string> dirs;                  
 88   words(PATH,psep(),false,dirs); //or true ?      
 89                                                   
 90   return find_with_dirs(a_out,dirs,a_file,a_pa    
 91 }                                                 
 92                                                   
 93 }                                                 
 94                                                   
 95 #endif