From 956a9b6429dace9b541126402cc5626f17d3c19a Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Mon, 18 Aug 2014 14:22:18 +0200 Subject: [PATCH] Pass file name as std::string to readFileAsString For consistency, use C++ strings as much as possible in interfaces. --- src/linkapp.cpp | 2 +- src/utilities.cpp | 2 +- src/utilities.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/linkapp.cpp b/src/linkapp.cpp index 98eac62..ad0b56e 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -523,7 +523,7 @@ void LinkApp::showManual() { // Txt manuals 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); tmd.exec(); return; diff --git a/src/utilities.cpp b/src/utilities.cpp index 54ecf0e..0bbf636 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -58,7 +58,7 @@ string rtrim(const string& s) { // See this article for a performance comparison of different approaches: // 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); if (!in) { return ""; diff --git a/src/utilities.h b/src/utilities.h index 2d84e39..cd442ac 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -47,7 +47,7 @@ std::string ltrim(const std::string& s); std::string rtrim(const std::string& s); /** 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 cmdclean(std::string cmdline);