mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2025-04-21 12:27:27 +03:00
Made text file reading more efficient and robust
Instead of reading the file line by line and then concatenating those lines, just load the entire thing in one go. And pay more attention to error conditions.
This commit is contained in:
@@ -491,18 +491,9 @@ void LinkApp::showManual() {
|
||||
|
||||
// Txt manuals
|
||||
if (manual.substr(manual.size()-8,8)==".man.txt") {
|
||||
string str, line;
|
||||
ifstream infile(manual.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
while (getline(infile, line, '\n')) {
|
||||
str.append(line).append("\n");
|
||||
}
|
||||
infile.close();
|
||||
|
||||
TextManualDialog tmd(gmenu2x, getTitle(), getIconPath(), str);
|
||||
tmd.exec();
|
||||
}
|
||||
|
||||
string text(readFileAsString(manual.c_str()));
|
||||
TextManualDialog tmd(gmenu2x, getTitle(), getIconPath(), text);
|
||||
tmd.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user