Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ProcessSmartlib(const string& s, long level = 0){
- // Try to match it to smartlibs, include source counterparts when possible
- if(!fileExists(s) || alreadyProcessed(s)) return;
- for(long i=0; i<level; i++) io::write('\t');
- io::writeln("%", s);
- processedSmartlibs.push_back(s);
- ifstream f(s);
- while(f.good()){
- string buffer = "";
- std::getline(f, buffer);
- if(buffer.find("#include") < buffer.size()){
- uint start = buffer.find("<", buffer.find("#include"));
- uint end;
- if(start >= buffer.size()){
- start = buffer.find("\"");
- if(start > buffer.size())
- continue;
- end = buffer.find("\"", start+1);
- }else
- end = buffer.find(">", start+1);
- if(start < buffer.size() && end < buffer.size() && end > start){
- string path = buffer.substr(start+1, end-start-1);
- for(string& l: smartLibs){
- if(fileExists(l + "/" + path)){
- string srcPath = l + "/" + path.substr(0, path.find_last_of('.')) + ".cpp";
- if(fileExists(srcPath) && !alreadyProcessed(srcPath))
- sourceFiles.push_back(srcPath);
- ProcessSmartlib(srcPath, level + 1);
- ProcessSmartlib(l + "/" + path, level + 1);
- }
- }
- }
- }
- }
- f.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement