diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 6fc811b67..cf0e3388c 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1454,7 +1454,7 @@ bool CRecordManager::RunStartScript(void) return false; puts("[neutrino.cpp] executing " NEUTRINO_RECORDING_START_SCRIPT "."); - if (my_system(NEUTRINO_RECORDING_START_SCRIPT,NULL,NULL) != 0) { + if (file_exists(NEUTRINO_RECORDING_START_SCRIPT) && my_system(NEUTRINO_RECORDING_START_SCRIPT,NULL,NULL) != 0) { perror(NEUTRINO_RECORDING_START_SCRIPT " failed"); return false; } @@ -1468,7 +1468,7 @@ bool CRecordManager::RunStopScript(void) return false; puts("[neutrino.cpp] executing " NEUTRINO_RECORDING_ENDED_SCRIPT "."); - if (my_system(NEUTRINO_RECORDING_ENDED_SCRIPT,NULL,NULL) != 0) { + if (file_exists(NEUTRINO_RECORDING_ENDED_SCRIPT) && my_system(NEUTRINO_RECORDING_ENDED_SCRIPT,NULL,NULL) != 0) { perror(NEUTRINO_RECORDING_ENDED_SCRIPT " failed"); return false; } diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 96424233b..2a7b74855 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -318,7 +318,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) g_Sectionsd->setPauseScanning(true); puts("[audioplayer.cpp] executing " AUDIOPLAYER_START_SCRIPT "."); - if (my_system(AUDIOPLAYER_START_SCRIPT,NULL,NULL) != 0) + if (file_exists(AUDIOPLAYER_START_SCRIPT) && my_system(AUDIOPLAYER_START_SCRIPT,NULL,NULL) != 0) perror("Datei " AUDIOPLAYER_START_SCRIPT " fehlt.Bitte erstellen, wenn gebraucht.\nFile " AUDIOPLAYER_START_SCRIPT " not found. Please create if needed.\n"); show(); @@ -330,7 +330,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) m_frameBuffer->paintBackground(); puts("[audioplayer.cpp] executing " AUDIOPLAYER_END_SCRIPT "."); - if (my_system(AUDIOPLAYER_END_SCRIPT,NULL,NULL) != 0) + if (file_exists(AUDIOPLAYER_END_SCRIPT) && my_system(AUDIOPLAYER_END_SCRIPT,NULL,NULL) != 0) perror("Datei " AUDIOPLAYER_END_SCRIPT " fehlt. Bitte erstellen, wenn gebraucht.\nFile " AUDIOPLAYER_END_SCRIPT " not found. Please create if needed.\n"); g_Zapit->unlockPlayBack(); diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index a51e04ff9..f35e55c4d 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -176,7 +176,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) startposition = 0; puts("[movieplayer.cpp] executing " MOVIEPLAYER_START_SCRIPT "."); - if (my_system(MOVIEPLAYER_START_SCRIPT,NULL,NULL) != 0) + if (file_exists(MOVIEPLAYER_START_SCRIPT) && my_system(MOVIEPLAYER_START_SCRIPT,NULL,NULL) != 0) perror(MOVIEPLAYER_START_SCRIPT " failed"); isMovieBrowser = false; @@ -214,7 +214,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) bookmarkmanager->flush(); puts("[movieplayer.cpp] executing " MOVIEPLAYER_END_SCRIPT "."); - if (my_system(MOVIEPLAYER_END_SCRIPT,NULL,NULL) != 0) + if (file_exists(MOVIEPLAYER_END_SCRIPT) && my_system(MOVIEPLAYER_END_SCRIPT,NULL,NULL) != 0) perror(MOVIEPLAYER_END_SCRIPT " failed"); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); @@ -301,7 +301,7 @@ bool CMoviePlayerGui::SelectFile() printf("CMoviePlayerGui::SelectFile: isBookmark %d timeshift %d isMovieBrowser %d\n", isBookmark, timeshift, isMovieBrowser); if (has_hdd) - system("(rm /hdd/.wakeup; touch /hdd/.wakeup; sync) > /dev/null 2> /dev/null &"); + wakeup_hdd(g_settings.network_nfs_recordingdir); if (timeshift) { t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); diff --git a/src/gui/plugins.cpp b/src/gui/plugins.cpp index 8a0e1c7e9..06b8b88e8 100644 --- a/src/gui/plugins.cpp +++ b/src/gui/plugins.cpp @@ -96,18 +96,6 @@ int CPlugins::find_plugin(const std::string & filename) return -1; } -bool CPlugins::pluginfile_exists(const std::string & filename) -{ - struct stat stat_buf; - if(::stat(filename.c_str(), &stat_buf) == 0) - { - return true; - } else - { - return false; - } -} - void CPlugins::scanDir(const char *dir) { struct dirent **namelist; @@ -370,7 +358,7 @@ void CPlugins::startScriptPlugin(int number) { const char *script = plugin_list[number].pluginfile.c_str(); printf("[CPlugins] executing script %s\n",script); - if (!pluginfile_exists(plugin_list[number].pluginfile)) + if (!file_exists(script)) { printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n", script, plugin_list[number].cfgfile.c_str()); @@ -423,7 +411,7 @@ void CPlugins::startPlugin(int number,int /*param*/) startScriptPlugin(number); return; } - if (!pluginfile_exists(plugin_list[number].pluginfile)) + if (!file_exists(plugin_list[number].pluginfile.c_str())) { printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n", plugin_list[number].pluginfile.c_str(), plugin_list[number].cfgfile.c_str()); diff --git a/src/gui/plugins.h b/src/gui/plugins.h index 9fab562b2..f37cc0704 100644 --- a/src/gui/plugins.h +++ b/src/gui/plugins.h @@ -97,7 +97,6 @@ class CPlugins void scanDir(const char *dir); bool plugin_exists(const std::string & filename); int find_plugin(const std::string & filename); - bool pluginfile_exists(const std::string & filename); CPlugins::p_type_t getPluginType(int type); public: CPlugins(); diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 7b66492b4..0c6587f83 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -249,7 +249,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) if(!manual) { g_RCInput->close_click(); - if (my_system(NEUTRINO_SCAN_START_SCRIPT,NULL,NULL) != 0) + if (file_exists(NEUTRINO_SCAN_START_SCRIPT) && my_system(NEUTRINO_SCAN_START_SCRIPT,NULL,NULL) != 0) perror(NEUTRINO_SCAN_START_SCRIPT " failed"); } @@ -311,7 +311,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) g_Zapit->stopScan(); if(!manual) { - if (my_system(NEUTRINO_SCAN_STOP_SCRIPT,NULL,NULL) != 0) + if (file_exists(NEUTRINO_SCAN_STOP_SCRIPT) && my_system(NEUTRINO_SCAN_STOP_SCRIPT,NULL,NULL) != 0) perror(NEUTRINO_SCAN_STOP_SCRIPT " failed"); g_RCInput->open_click(); } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 6879eaa1e..01cb36036 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2687,7 +2687,8 @@ _repeat: return messages_return::handled; } else if( msg == NeutrinoMessages::ANNOUNCE_RECORD) { - my_system(NEUTRINO_RECORDING_TIMER_SCRIPT,NULL,NULL); + if(file_exists(NEUTRINO_RECORDING_TIMER_SCRIPT)) + my_system(NEUTRINO_RECORDING_TIMER_SCRIPT,NULL,NULL); if (g_settings.recording_type == RECORDING_FILE) { char * recordingDir = ((CTimerd::RecordingInfo*)data)->recordingDir; for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { @@ -2701,7 +2702,7 @@ _repeat: } } if(has_hdd) { - system("(rm /media/sda1/.wakeup; touch /media/sda1/.wakeup; sync) > /dev/null 2> /dev/null &"); // wakeup hdd + wakeup_hdd(g_settings.network_nfs_recordingdir); } } if( g_settings.recording_zap_on_announce ) { @@ -3225,7 +3226,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) standby_channel_id = CZapit::getInstance()->GetCurrentChannelID(); puts("[neutrino.cpp] executing " NEUTRINO_ENTER_STANDBY_SCRIPT "."); - if (my_system(NEUTRINO_ENTER_STANDBY_SCRIPT,NULL,NULL) != 0) + if (file_exists(NEUTRINO_ENTER_STANDBY_SCRIPT) && my_system(NEUTRINO_ENTER_STANDBY_SCRIPT,NULL,NULL) != 0) perror(NEUTRINO_ENTER_STANDBY_SCRIPT " failed"); if(!CRecordManager::getInstance()->RecordingStatus()) @@ -3269,7 +3270,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) } puts("[neutrino.cpp] executing " NEUTRINO_LEAVE_STANDBY_SCRIPT "."); - if (my_system(NEUTRINO_LEAVE_STANDBY_SCRIPT,NULL,NULL) != 0) + if (file_exists(NEUTRINO_LEAVE_STANDBY_SCRIPT) && my_system(NEUTRINO_LEAVE_STANDBY_SCRIPT,NULL,NULL) != 0) perror(NEUTRINO_LEAVE_STANDBY_SCRIPT " failed"); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index bd4d598ab..6038eea98 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -32,9 +32,33 @@ #include #include /* or */ #include +#include #include +bool file_exists(const char *filename) +{ + struct stat stat_buf; + if(::stat(filename, &stat_buf) == 0) + { + return true; + } else + { + return false; + } +} + +void wakeup_hdd(const char *hdd_dir) +{ + if(!check_dir(hdd_dir)){ + std::string wakeup_file = hdd_dir; + wakeup_file += "/.wakeup"; + remove(wakeup_file.c_str()); + creat(wakeup_file.c_str(),S_IREAD|S_IWRITE); + sync(); + } +} + int my_system(const char * cmd, const char * arg1, const char * arg2) { int i; diff --git a/src/system/helpers.h b/src/system/helpers.h index 29f96dd4c..ec3074d6c 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -26,5 +26,7 @@ int my_system(const char * cmd, const char * arg1, const char * arg2); FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type); int safe_mkdir(char * path); int check_dir(const char * newdir); +bool file_exists(const char *filename); +void wakeup_hdd(const char *hdd_dir); #endif