我是一个完全的初学者,我有这个功能,我使用 .eof 但是我被告知这不是一个好主意,因为这不适用于 linux,我应该使用 .good 所以你能告诉我我会做什么以及我应该如何修改它
std::string ex_file_licensing::getUsedLicense(const std::string &FlexLMfileName){
std::ofstream openFile;
std::string line;
std::string tempString;
std::string testResult;
size_t start_pos;
size_t stop_pos;
std::string retour ="";
filebuf fb;
fb.open (FlexLMfileName.c_str(),ios::in);
istream toOpen(&fb);
if(toOpen.eof()){
while(!toOpen.eof()){
getline(toOpen,line);
if(line.find("Checkout") != std::string::npos ){
start_pos = line.find(":");
tempString = line.substr(start_pos+1);
stop_pos = tempString.find("/");
testResult = tempString.substr(start_pos, stop_pos);
}
else if (line.find("FLEXnet") != std::string::npos ){
start_pos = line.find("FLEXnet");
tempString = line.substr(start_pos+1);
stop_pos = tempString.find("Feature");
testResult = tempString.substr(start_pos, stop_pos);
}
cout << testResult << endl;
retour.append(testResult);
}
fb.close();
}
return retour;
}