From cc637739206cf903a2897cbad3cb945c5539381f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 24 Apr 2013 00:43:55 +0200 Subject: [PATCH] CComponentsText: add bool as return value for setTextFromFile() --- src/gui/components/cc.h | 2 +- src/gui/components/cc_item_text.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 41dc770bb..deeea86af 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -213,7 +213,7 @@ class CComponentsText : public CComponentsItem virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); - virtual void setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); + virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void removeLineBreaks(std::string& str); //get a Text Box object, so it's possible to get access directly to its methods diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 916a67231..6b7efcf9c 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -191,8 +191,8 @@ void CComponentsText::setText(const int digit, const int mode, Font* font_text) #endif } -//set text lines directly from a file -void CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text) +//set text lines directly from a file, returns true on succsess +bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text) { string file = path_to_textfile; string txt = ""; @@ -200,7 +200,7 @@ void CComponentsText::setTextFromFile(const string& path_to_textfile, const int ifstream in (file.c_str(), ios::in); if (!in){ printf("[CComponentsText] [%s - %d] error while open %s -> %s\n", __FUNCTION__, __LINE__, file.c_str(), strerror(errno)); - return; + return false; } string line; @@ -210,6 +210,8 @@ void CComponentsText::setTextFromFile(const string& path_to_textfile, const int in.close(); setText(txt, mode, font_text); + + return true; } void CComponentsText::paintText(bool do_save_bg)