1
0
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:
Maarten ter Huurne
2014-07-24 10:41:20 +02:00
parent d0de870180
commit 485bab3b48
4 changed files with 46 additions and 45 deletions

View File

@@ -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;
}