Advertisement
WeltEnSTurm

Untitled

Apr 5th, 2012
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1.  
  2.             void ProcessSmartlib(const string& s, long level = 0){
  3.                 // Try to match it to smartlibs, include source counterparts when possible
  4.                 if(!fileExists(s) || alreadyProcessed(s)) return;
  5.                 for(long i=0; i<level; i++) io::write('\t');
  6.                 io::writeln("%", s);
  7.                 processedSmartlibs.push_back(s);
  8.                 ifstream f(s);
  9.                 while(f.good()){
  10.                     string buffer = "";
  11.                     std::getline(f, buffer);
  12.  
  13.                     if(buffer.find("#include") < buffer.size()){
  14.                         uint start = buffer.find("<", buffer.find("#include"));
  15.                         uint end;
  16.                         if(start >= buffer.size()){
  17.                             start = buffer.find("\"");
  18.                             if(start > buffer.size())
  19.                                 continue;
  20.                             end = buffer.find("\"", start+1);
  21.                         }else
  22.                             end = buffer.find(">", start+1);
  23.                         if(start < buffer.size() && end < buffer.size() && end > start){
  24.                             string path = buffer.substr(start+1, end-start-1);
  25.                             for(string& l: smartLibs){
  26.                                 if(fileExists(l + "/" + path)){
  27.                                     string srcPath = l + "/" + path.substr(0, path.find_last_of('.')) + ".cpp";
  28.                                     if(fileExists(srcPath) && !alreadyProcessed(srcPath))
  29.                                         sourceFiles.push_back(srcPath);
  30.                                     ProcessSmartlib(srcPath, level + 1);
  31.                                     ProcessSmartlib(l + "/" + path, level + 1);
  32.                                 }
  33.                             }
  34.                         }
  35.                     }
  36.  
  37.                 }
  38.                 f.close();
  39.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement