Created
June 19, 2021 10:48
-
-
Save sritasngh/c0bc32b2895ae67540d8eeabdb4e418b to your computer and use it in GitHub Desktop.
This code works to find starting and ending pointer to highlight matched license text as scanned by scancode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned long getFilePointer(const string& filename, | |
size_t start_line, | |
const string& match_text){ | |
ifstream checkfile(filename); | |
string str; | |
if(checkfile.is_open()){ | |
for (size_t i = 0; i <start_line-1; i++) | |
{ | |
getline(checkfile, str); | |
} | |
int file_p = checkfile.tellg(); | |
getline(checkfile, str); | |
cout<< "Checkline="<<str<<"\n"; | |
unsigned int pos= str.find(match_text); | |
if(pos!=string::npos){ | |
return file_p+pos; | |
} | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment