overload access(2)

Conflicts:
	src/driver/pictureviewer/pictureviewer.cpp
	src/gui/components/cc_item_picture.cpp
	src/gui/movieplayer.cpp
	src/gui/osdlang_setup.cpp
	src/neutrino.cpp
	src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp
	src/nhttpd/yhttpd.cpp
	src/system/helpers.h
	src/system/setting_helpers.cpp
This commit is contained in:
martii
2013-06-30 17:00:34 +02:00
committed by [CST] Focus
parent d56b7da446
commit 81ca577fb8
14 changed files with 42 additions and 28 deletions

View File

@@ -392,7 +392,7 @@ void CFileBrowser::ChangeDir(const std::string & filename, int selection)
std::string extension = file->Name.substr(ext_pos + 1, name.length() - ext_pos); std::string extension = file->Name.substr(ext_pos + 1, name.length() - ext_pos);
if(strcasecmp(extension.c_str(), "ts") == 0) { if(strcasecmp(extension.c_str(), "ts") == 0) {
std::string fname = file->Name.substr(0, ext_pos) + ".xml"; std::string fname = file->Name.substr(0, ext_pos) + ".xml";
if(access(fname.c_str(), F_OK) == 0) if(access(fname, F_OK) == 0)
continue; continue;
} }
} }

View File

@@ -1307,7 +1307,7 @@ std::string CMovieBrowser::getScreenshotName(std::string movie)
ext = *it; ext = *it;
ret.replace(found, ext.length(), ext); ret.replace(found, ext.length(), ext);
++it; ++it;
if (!access(ret.c_str(), F_OK)) if (!access(ret, F_OK))
return ret; return ret;
} }
return ""; return "";

View File

@@ -68,7 +68,7 @@ CNetworkService::CNetworkService(std::string cmd, std::string opts)
enabled = false; enabled = false;
std::string file = TOUCH_BASE + cmd; std::string file = TOUCH_BASE + cmd;
if (!access(file.c_str(), F_OK)) if (!access(file, F_OK))
enabled = true; enabled = true;
} }
@@ -181,7 +181,7 @@ int CNetworkServiceSetup::showNetworkServiceSetup()
std::string execute2 = "/sbin/" + services[i].cmd; std::string execute2 = "/sbin/" + services[i].cmd;
active = false; active = false;
if ( !(access(execute1.c_str(), F_OK)) || !(access(execute2.c_str(), F_OK)) ) if ( !(access(execute1, F_OK)) || !(access(execute2, F_OK)) )
active = true; active = true;
if ( (services[i].name == "Telnet") && useinetd) if ( (services[i].name == "Telnet") && useinetd)

View File

@@ -46,6 +46,7 @@
#include <driver/screen_max.h> #include <driver/screen_max.h>
#include <xmlinterface.h> #include <xmlinterface.h>
#include <system/helpers.h>
#include <system/debug.h> #include <system/debug.h>
#include <algorithm> #include <algorithm>
@@ -145,10 +146,15 @@ CMenuOptionStringChooser* COsdLangSetup::getTzItems()
if (!strcmp(xmlGetName(search), "zone")) if (!strcmp(xmlGetName(search), "zone"))
{ {
std::string name = xmlGetAttribute(search, "name"); std::string name = xmlGetAttribute(search, "name");
// std::string zone = xmlGetAttribute(search, "zone"); std::string zone = xmlGetAttribute(search, "zone");
//printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); //printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str());
tzSelect->addOption(name.c_str()); if (access("/usr/share/zoneinfo/" + zone, R_OK))
found = true; printf("[neutrino] timezone file '%s' not installed\n", zone.c_str());
else
{
tzSelect->addOption(name);
found = true;
}
} }
search = search->xmlNextNode; search = search->xmlNextNode;
} }

View File

@@ -316,7 +316,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std:
std::string timestr; std::string timestr;
bool have_logos = false; bool have_logos = false;
if(hh->WebserverConfigList["TUXBOX_LOGOS_URL"] != "" ||hh->WebserverConfigList["ExtrasDocumentRoot"] == "web" || (access((hh->WebserverConfigList["ExtrasDocumentRoot"]+"/logos").c_str(),4)==0) ) if(hh->WebserverConfigList["TUXBOX_LOGOS_URL"] != "" ||hh->WebserverConfigList["ExtrasDocumentRoot"] == "web" || (access(hh->WebserverConfigList["ExtrasDocumentRoot"]+"/logos",R_OK)==0) )
have_logos = true; have_logos = true;
CZapitClient::BouquetChannelList::iterator channel = channellist->begin(); CZapitClient::BouquetChannelList::iterator channel = channellist->begin();
for (; channel != channellist->end();channel++) for (; channel != channellist->end();channel++)

View File

@@ -13,6 +13,7 @@
#include <stdio.h> #include <stdio.h>
#include <system/set_threadname.h> #include <system/set_threadname.h>
#include <system/helpers.h>
// yhttpd // yhttpd
#include "yconfig.h" #include "yconfig.h"
#include <ylogging.h> #include <ylogging.h>
@@ -549,16 +550,16 @@ void Cyhttpd::ReadConfig(void) {
// Check location of logos // Check location of logos
if (Config->getString("Tuxbox.LogosURL", "") == "") { if (Config->getString("Tuxbox.LogosURL", "") == "") {
if (access(std::string(ConfigList["WebsiteMain.override_directory"] + "/logos").c_str(), R_OK) == 0) { if (access(ConfigList["WebsiteMain.override_directory"] + "/logos", R_OK) == 0) {
Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.override_directory"] + "/logos"); Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.override_directory"] + "/logos");
have_config = false; //save config have_config = false; //save config
} }
else if (access(std::string(ConfigList["WebsiteMain.directory"] + "/logos").c_str(), R_OK) == 0) { else if (access(ConfigList["WebsiteMain.directory"] + "/logos", R_OK) == 0){
Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.directory"] + "/logos"); Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.directory"] + "/logos");
have_config = false; //save config have_config = false; //save config
} }
#ifdef Y_CONFIG_USE_HOSTEDWEB #ifdef Y_CONFIG_USE_HOSTEDWEB
else if (access(std::string(ConfigList["WebsiteMain.hosted_directory"] + "/logos").c_str(), R_OK) == 0) { else if (access(ConfigList["WebsiteMain.hosted_directory"] + "/logos", R_OK) == 0){
Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.hosted_directory"] + "/logos"); Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.hosted_directory"] + "/logos");
have_config = false; //save config have_config = false; //save config
} }

View File

@@ -9,6 +9,8 @@
#include <cstdlib> #include <cstdlib>
#include <unistd.h> #include <unistd.h>
#include <system/helpers.h>
// yhttpd // yhttpd
#include <yconfig.h> #include <yconfig.h>
#include <yhttpd.h> #include <yhttpd.h>
@@ -109,9 +111,9 @@ std::string CLanguage::getTranslation(std::string id){
std::string CLanguage::getLanguageDir(void){ std::string CLanguage::getLanguageDir(void){
std::string tmpfilename = "/"+Cyhttpd::ConfigList["Language.directory"],dir=""; std::string tmpfilename = "/"+Cyhttpd::ConfigList["Language.directory"],dir="";
if( access(std::string(Cyhttpd::ConfigList["WebsiteMain.override_directory"] + tmpfilename).c_str(),4) == 0) if( access(Cyhttpd::ConfigList["WebsiteMain.override_directory"] + tmpfilename,R_OK) == 0)
dir = Cyhttpd::ConfigList["WebsiteMain.override_directory"] + tmpfilename; dir = Cyhttpd::ConfigList["WebsiteMain.override_directory"] + tmpfilename;
else if(access(std::string(Cyhttpd::ConfigList["WebsiteMain.directory"] + tmpfilename).c_str(),4) == 0) else if(access(Cyhttpd::ConfigList["WebsiteMain.directory"] + tmpfilename,R_OK) == 0)
dir = Cyhttpd::ConfigList["WebsiteMain.directory"] + tmpfilename; dir = Cyhttpd::ConfigList["WebsiteMain.directory"] + tmpfilename;
return dir; return dir;
} }

View File

@@ -46,6 +46,7 @@
#include <pthread.h> #include <pthread.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <system/helpers.h>
// yhttpd // yhttpd
#include <yconfig.h> #include <yconfig.h>
#include <ytypes_globals.h> #include <ytypes_globals.h>
@@ -179,16 +180,16 @@ std::string CmodSendfile::GetFileName(CyhookHandler *hh, std::string path, std::
tmpfilename = path + "/" + filename; tmpfilename = path + "/" + filename;
else else
tmpfilename = path + filename; tmpfilename = path + filename;
if (access(std::string(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename).c_str(), 4) == 0) if (access(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename, R_OK) == 0)
tmpfilename = hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename; tmpfilename = hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename;
else if (access(std::string(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename + ".gz").c_str(), 4) == 0) else if (access(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename + ".gz", R_OK) == 0)
tmpfilename = hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename + ".gz"; tmpfilename = hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename + ".gz";
else if (access(std::string(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename).c_str(), 4) == 0) else if (access(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename, R_OK) == 0)
tmpfilename = hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename; tmpfilename = hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename;
else if (access(std::string(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename + ".gz").c_str(), 4) == 0) else if (access(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename + ".gz", R_OK) == 0)
tmpfilename = hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename + ".gz"; tmpfilename = hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename + ".gz";
#ifdef Y_CONFIG_FEATUE_SENDFILE_CAN_ACCESS_ALL #ifdef Y_CONFIG_FEATUE_SENDFILE_CAN_ACCESS_ALL
else if(access(tmpfilename.c_str(),4) == 0) else if(access(tmpfilename,R_OK) == 0)
; ;
#endif #endif
else { else {

View File

@@ -12,6 +12,7 @@
#include "mod_weblog.h" #include "mod_weblog.h"
#include <helper.h> #include <helper.h>
#include <system/helpers.h>
//============================================================================= //=============================================================================
// Initialization of static variables // Initialization of static variables
@@ -67,7 +68,7 @@ bool CmWebLog::OpenLogFile() {
if (WebLogFile == NULL) { if (WebLogFile == NULL) {
bool isNew = false; bool isNew = false;
pthread_mutex_lock(&WebLog_mutex); // yeah, its mine pthread_mutex_lock(&WebLog_mutex); // yeah, its mine
if (access(WebLogFilename.c_str(), 4) != 0) if (access(WebLogFilename, R_OK) != 0)
isNew = true; isNew = true;
WebLogFile = fopen(WebLogFilename.c_str(), "a"); WebLogFile = fopen(WebLogFilename.c_str(), "a");
if (isNew) { if (isNew) {

View File

@@ -19,6 +19,7 @@
#include <signal.h> #include <signal.h>
// tuxbox // tuxbox
#include <configfile.h> #include <configfile.h>
#include <system/helpers.h>
// yhttpd // yhttpd
#include <yconfig.h> #include <yconfig.h>
#include <ytypes_globals.h> #include <ytypes_globals.h>
@@ -423,7 +424,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) {
std::string if_value, if_then, if_else; std::string if_value, if_then, if_else;
if (ySplitString(ycmd_name, "~", if_value, if_then)) { if (ySplitString(ycmd_name, "~", if_value, if_then)) {
ySplitString(if_then, "~", if_then, if_else); ySplitString(if_then, "~", if_then, if_else);
yresult = (access(if_value.c_str(), 4) == 0) ? if_then yresult = (access(if_value, R_OK) == 0) ? if_then
: if_else; : if_else;
} }
} else if (ycmd_type == "include") { } else if (ycmd_type == "include") {
@@ -731,7 +732,7 @@ std::string CyParser::func_do_reload_httpd_config(CyhookHandler *, std::string)
// y-func : Change httpd (process image) on the fly // y-func : Change httpd (process image) on the fly
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
std::string CyParser::func_change_httpd(CyhookHandler *hh, std::string para) { std::string CyParser::func_change_httpd(CyhookHandler *hh, std::string para) {
if (para != "" && access(para.c_str(), 4) == 0) { if (para != "" && access(para, R_OK) == 0) {
hh->status = HANDLED_ABORT; hh->status = HANDLED_ABORT;
char * argv[2] = { (char *)para.c_str(), NULL }; char * argv[2] = { (char *)para.c_str(), NULL };
int err = execvp(argv[0], argv); // no return if successful int err = execvp(argv[0], argv); // no return if successful

View File

@@ -104,7 +104,7 @@ void CNetworkConfig::init_vars(void)
wireless = 0; wireless = 0;
std::string tmp = "/sys/class/net/" + ifname + "/wireless"; std::string tmp = "/sys/class/net/" + ifname + "/wireless";
if(access(tmp.c_str(), R_OK) == 0) if(access(tmp, R_OK) == 0)
wireless = 1; wireless = 1;
if(wireless) if(wireless)
readWpaConfig(); readWpaConfig();

View File

@@ -466,7 +466,8 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data)
name = xmlGetAttribute(search, "name"); name = xmlGetAttribute(search, "name");
if(g_settings.timezone == name) { if(g_settings.timezone == name) {
zone = xmlGetAttribute(search, "zone"); zone = xmlGetAttribute(search, "zone");
found = true; if (!access("/usr/share/zoneinfo/" + zone, R_OK))
found = true;
break; break;
} }
} }

View File

@@ -69,7 +69,7 @@ bool cYTCache::getNameIfExists(std::string &fname, const std::string &id, int it
char ytitag[10]; char ytitag[10];
snprintf(ytitag, sizeof(ytitag), "%d", itag); snprintf(ytitag, sizeof(ytitag), "%d", itag);
std::string f = g_settings.downloadcache_dir + "/" + id + "-" + std::string(ytitag) + "." + ext; std::string f = g_settings.downloadcache_dir + "/" + id + "-" + std::string(ytitag) + "." + ext;
if (access(f.c_str(), R_OK)) if (access(f, R_OK))
return false; return false;
fname = f; fname = f;
return true; return true;
@@ -78,10 +78,10 @@ bool cYTCache::getNameIfExists(std::string &fname, const std::string &id, int it
bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi) bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi)
{ {
std::string file = getName(mi); std::string file = getName(mi);
if (access(file.c_str(), R_OK)) if (access(file, R_OK))
return false; return false;
std::string xml = getName(mi, "xml"); std::string xml = getName(mi, "xml");
if (!access(xml.c_str(), R_OK)) { if (!access(xml, R_OK)) {
mi->file.Url = file; mi->file.Url = file;
return true; return true;
} }
@@ -111,7 +111,7 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
{ {
std::string file = getName(mi); std::string file = getName(mi);
std::string xml = getName(mi, "xml"); std::string xml = getName(mi, "xml");
if (!access(file.c_str(), R_OK) && !access(xml.c_str(), R_OK)) { if (!access(file, R_OK) && !access(xml, R_OK)) {
fprintf(stderr, "%s: %s already present and valid\n", __func__, file.c_str()); fprintf(stderr, "%s: %s already present and valid\n", __func__, file.c_str());
return true; return true;
} }

View File

@@ -32,6 +32,7 @@
#include <OpenThreads/ScopedLock> #include <OpenThreads/ScopedLock>
#include "settings.h" #include "settings.h"
#include "helpers.h"
#include "set_threadname.h" #include "set_threadname.h"
#include <global.h> #include <global.h>
@@ -615,7 +616,7 @@ bool cYTFeedParser::DownloadThumbnail(cYTVideoInfo &vinfo, CURL *_curl_handle)
bool found = false; bool found = false;
if (!vinfo.thumbnail.empty()) { if (!vinfo.thumbnail.empty()) {
std::string fname = thumbnail_dir + "/" + vinfo.id + ".jpg"; std::string fname = thumbnail_dir + "/" + vinfo.id + ".jpg";
found = !access(fname.c_str(), F_OK); found = !access(fname, F_OK);
if (!found) { if (!found) {
for (int *fmtp = itags; *fmtp && !found; fmtp++) for (int *fmtp = itags; *fmtp && !found; fmtp++)
found = cYTCache::getInstance()->getNameIfExists(fname, vinfo.id, *fmtp); found = cYTCache::getInstance()->getNameIfExists(fname, vinfo.id, *fmtp);