mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 15:02:50 +02:00
fb_generic: use file_exists() in getIconPath()
* fix icons with absolute path
* rename path => icon
Origin commit data
------------------
Branch: ni/coolstream
Commit: 02713f8679
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-10-29 (Fri, 29 Oct 2021)
Origin message was:
------------------
- fb_generic: use file_exists() in getIconPath()
* fix icons with absolute path
* rename path => icon
------------------
This commit was generated by Migit
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include <gui/osd_helpers.h>
|
||||
#include <gui/pictureviewer.h>
|
||||
#include <system/debug.h>
|
||||
#include <system/helpers.h>
|
||||
#include <global.h>
|
||||
#include <hardware/video.h>
|
||||
#include <cs_api.h>
|
||||
@@ -698,20 +699,19 @@ void CFrameBuffer::setIconBasePath(const std::string & iconPath)
|
||||
|
||||
std::string CFrameBuffer::getIconPath(std::string icon_name, std::string file_type)
|
||||
{
|
||||
// why search when we have an absolut path?
|
||||
if (icon_name.find("/", 0) != std::string::npos)
|
||||
if ((icon_name.find("/", 0) != std::string::npos) && file_exists(icon_name))
|
||||
return icon_name;
|
||||
|
||||
std::vector<std::string> filetypes = { ".svg", ".png", ".jpg" };
|
||||
std::string path = icon_name;
|
||||
std::string icon = icon_name;
|
||||
|
||||
std::string::size_type pos = icon_name.find_last_of(".");
|
||||
std::string::size_type pos = icon.find_last_of(".");
|
||||
if (pos != std::string::npos && file_type.empty())
|
||||
{
|
||||
if (std::find(filetypes.begin(), filetypes.end(), icon_name.substr(pos)) != filetypes.end())
|
||||
{
|
||||
icon_name = path.substr(0, pos);
|
||||
file_type = path.substr(pos + 1);
|
||||
icon_name = icon.substr(0, pos);
|
||||
file_type = icon.substr(pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,11 +733,9 @@ std::string CFrameBuffer::getIconPath(std::string icon_name, std::string file_ty
|
||||
{
|
||||
for (unsigned int i = 0; i < dir.size(); i++)
|
||||
{
|
||||
path = std::string(dir[i]) + "/" + icon_name + filetypes[t];
|
||||
if (access(path.c_str(), F_OK) == 0)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
icon = std::string(dir[i]) + "/" + icon_name + filetypes[t];
|
||||
if (file_exists(icon))
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user