1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-16 17:17:32 +02:00

Pass file name as std::string to readFileAsString

For consistency, use C++ strings as much as possible in interfaces.
This commit is contained in:
Maarten ter Huurne 2014-08-18 14:22:18 +02:00
parent 07eefb219f
commit 956a9b6429
3 changed files with 3 additions and 3 deletions

View File

@ -523,7 +523,7 @@ void LinkApp::showManual() {
// Txt manuals // Txt manuals
if (manual.substr(manual.size()-8,8)==".man.txt") { if (manual.substr(manual.size()-8,8)==".man.txt") {
string text(readFileAsString(manual.c_str())); string text(readFileAsString(manual));
TextManualDialog tmd(gmenu2x, getTitle(), getIconPath(), text); TextManualDialog tmd(gmenu2x, getTitle(), getIconPath(), text);
tmd.exec(); tmd.exec();
return; return;

View File

@ -58,7 +58,7 @@ string rtrim(const string& s) {
// See this article for a performance comparison of different approaches: // See this article for a performance comparison of different approaches:
// http://insanecoding.blogspot.com/2011/11/how-to-read-in-file-in-c.html // http://insanecoding.blogspot.com/2011/11/how-to-read-in-file-in-c.html
string readFileAsString(const char *filename) { string readFileAsString(string const& filename) {
ifstream in(filename, ios::in | ios::binary); ifstream in(filename, ios::in | ios::binary);
if (!in) { if (!in) {
return "<error opening " + string(filename) + ">"; return "<error opening " + string(filename) + ">";

View File

@ -47,7 +47,7 @@ std::string ltrim(const std::string& s);
std::string rtrim(const std::string& s); std::string rtrim(const std::string& s);
/** Returns the contents of the given file as a string. */ /** Returns the contents of the given file as a string. */
std::string readFileAsString(const char *filename); std::string readFileAsString(std::string const& filename);
std::string strreplace(std::string orig, const std::string &search, const std::string &replace); std::string strreplace(std::string orig, const std::string &search, const std::string &replace);
std::string cmdclean(std::string cmdline); std::string cmdclean(std::string cmdline);