From e84c60f48aecc60d7289882d53b687920d223ef8 Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 26 Oct 2014 08:47:24 +0100 Subject: [PATCH] fixed bug that hasposter is only true if poster really exists --- HISTORY | 1 + libcore/helpers.c | 5 +++++ libcore/helpers.h | 1 + views/displaymenuitemcurrentview.c | 2 +- views/displaymenuitemview.c | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index b0d4423..a0f256d 100644 --- a/HISTORY +++ b/HISTORY @@ -37,6 +37,7 @@ Version 0.0.2 - added device info in displaychannel, example in metrixHD - improved menu icon display, additionally using menu cat - changed devices list, device numbers start with 0 +- fixed bug that hasposter is only true if poster really exists diff --git a/libcore/helpers.c b/libcore/helpers.c index 1934f3e..4ca2272 100644 --- a/libcore/helpers.c +++ b/libcore/helpers.c @@ -90,6 +90,11 @@ bool isNumber(const string& s) { return !s.empty() && it == s.end(); } +bool FileExists(const string &fullpath) { + struct stat buffer; + return (stat (fullpath.c_str(), &buffer) == 0); +} + bool FileExists(const string &path, const string &name, const string &ext) { stringstream fileName; fileName << path << name << "." << ext; diff --git a/libcore/helpers.h b/libcore/helpers.h index f489555..2a92efb 100644 --- a/libcore/helpers.h +++ b/libcore/helpers.h @@ -12,6 +12,7 @@ int Minimum(int a, int b, int c, int d, int e, int f); std::string CutText(string &text, int width, string fontName, int fontSize); std::string StrToLowerCase(string str); bool isNumber(const string& s); +bool FileExists(const string &fullpath); bool FileExists(const string &path, const string &name, const string &ext); bool FolderExists(const string &path); bool FirstFileInFolder(string &path, string &extension, string &fileName); diff --git a/views/displaymenuitemcurrentview.c b/views/displaymenuitemcurrentview.c index d9263c4..312b041 100644 --- a/views/displaymenuitemcurrentview.c +++ b/views/displaymenuitemcurrentview.c @@ -42,7 +42,7 @@ void cDisplayMenuItemCurrentView::SetScraperPoster(const cEvent *event, const cR call.event = event; call.recording = recording; if (pScraper->Service("GetPoster", &call)) { - intTokens.insert(pair("hasposter", true)); + intTokens.insert(pair("hasposter", FileExists(call.poster.path))); intTokens.insert(pair("posterwidth", call.poster.width)); intTokens.insert(pair("posterheight", call.poster.height)); stringTokens.insert(pair("posterpath", call.poster.path)); diff --git a/views/displaymenuitemview.c b/views/displaymenuitemview.c index 42901b5..5e995c5 100644 --- a/views/displaymenuitemview.c +++ b/views/displaymenuitemview.c @@ -706,7 +706,7 @@ void cDisplayMenuItemRecordingView::SetTokens(void) { call.event = NULL; call.recording = usedRecording; if (pScraper->Service("GetPosterThumb", &call)) { - intTokens.insert(pair("hasposterthumbnail", true)); + intTokens.insert(pair("hasposterthumbnail", FileExists(call.poster.path))); intTokens.insert(pair("thumbnailbwidth", call.poster.width)); intTokens.insert(pair("thumbnailheight", call.poster.height)); stringTokens.insert(pair("thumbnailpath", call.poster.path));