diff --git a/src/client.cpp b/src/client.cpp index e91212a16..35d8ad824 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -36,16 +36,6 @@ using namespace iptvsimple; using namespace iptvsimple::data; using namespace iptvsimple::utilities; -#ifdef TARGET_WINDOWS -#define snprintf _snprintf -#ifdef CreateDirectory -#undef CreateDirectory -#endif -#ifdef DeleteFile -#undef DeleteFile -#endif -#endif - bool m_created = false; ADDON_STATUS m_currentStatus = ADDON_STATUS_UNKNOWN; PVRIptvData* m_data = nullptr; @@ -118,9 +108,6 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props) const std::string userPath = pvrprops->strUserPath; const std::string clientPath = pvrprops->strClientPath; - if (!XBMC->DirectoryExists(settings.GetUserPath().c_str())) - XBMC->CreateDirectory(settings.GetUserPath().c_str()); - settings.ReadFromAddon(userPath, clientPath); m_data = new PVRIptvData; diff --git a/src/iptvsimple/Epg.cpp b/src/iptvsimple/Epg.cpp index c03854461..19afe2929 100644 --- a/src/iptvsimple/Epg.cpp +++ b/src/iptvsimple/Epg.cpp @@ -40,12 +40,6 @@ using namespace iptvsimple::data; using namespace iptvsimple::utilities; using namespace rapidxml; -#ifdef TARGET_WINDOWS -#ifdef DeleteFile -#undef DeleteFile -#endif -#endif - Epg::Epg(Channels& channels) : m_channels(channels), m_xmltvLocation(Settings::GetInstance().GetEpgLocation()), m_epgTimeShift(Settings::GetInstance().GetEpgTimeshiftSecs()), m_tsOverride(Settings::GetInstance().GetTsOverride()), m_lastStart(0), m_lastEnd(0) @@ -216,8 +210,7 @@ bool Epg::LoadChannelEpgs(xml_node<>* rootElement) m_channelEpgs.clear(); - xml_node<>* channelNode = nullptr; - for (channelNode = rootElement->first_node("channel"); channelNode; channelNode = channelNode->next_sibling("channel")) + for (xml_node<>* channelNode = rootElement->first_node("channel"); channelNode; channelNode = channelNode->next_sibling("channel")) { ChannelEpg channelEpg; @@ -473,6 +466,6 @@ void Epg::MoveOldGenresXMLFileToNewLocation() else FileUtils::CopyFile(FileUtils::GetResourceDataPath() + "/" + GENRES_MAP_FILENAME, DEFAULT_GENRE_TEXT_MAP_FILE); - XBMC->DeleteFile((ADDON_DATA_BASE_DIR + "/" + GENRES_MAP_FILENAME).c_str()); - XBMC->DeleteFile((FileUtils::GetSystemAddonPath() + "/" + GENRES_MAP_FILENAME).c_str()); + FileUtils::DeleteFile(ADDON_DATA_BASE_DIR + "/" + GENRES_MAP_FILENAME.c_str()); + FileUtils::DeleteFile(FileUtils::GetSystemAddonPath() + "/" + GENRES_MAP_FILENAME.c_str()); } diff --git a/src/iptvsimple/Settings.cpp b/src/iptvsimple/Settings.cpp index 2a1e7d70e..4e3065e24 100644 --- a/src/iptvsimple/Settings.cpp +++ b/src/iptvsimple/Settings.cpp @@ -29,12 +29,6 @@ using namespace ADDON; using namespace iptvsimple; using namespace iptvsimple::utilities; -#ifdef TARGET_WINDOWS -#ifdef DeleteFile -#undef DeleteFile -#endif -#endif - /*************************************************************************** * PVR settings **************************************************************************/ @@ -99,12 +93,12 @@ ADDON_STATUS Settings::SetValue(const std::string& settingName, const void* sett // reset cache and restart addon std::string strFile = FileUtils::GetUserDataAddonFilePath(M3U_CACHE_FILENAME); - if (XBMC->FileExists(strFile.c_str(), false)) - XBMC->DeleteFile(strFile.c_str()); + if (FileUtils::FileExists(strFile.c_str())) + FileUtils::DeleteFile(strFile); strFile = FileUtils::GetUserDataAddonFilePath(XMLTV_CACHE_FILENAME); - if (XBMC->FileExists(strFile.c_str(), false)) - XBMC->DeleteFile(strFile.c_str()); + if (FileUtils::FileExists(strFile.c_str())) + FileUtils::DeleteFile(strFile); // M3U if (settingName == "m3uPathType") diff --git a/src/iptvsimple/Settings.h b/src/iptvsimple/Settings.h index 2961da0c3..0c6a2485d 100644 --- a/src/iptvsimple/Settings.h +++ b/src/iptvsimple/Settings.h @@ -131,31 +131,31 @@ namespace iptvsimple return defaultReturnValue; } - std::string m_userPath = ""; - std::string m_clientPath = ""; + std::string m_userPath; + std::string m_clientPath; PathType m_m3uPathType = PathType::REMOTE_PATH; - std::string m_m3uPath = ""; - std::string m_m3uUrl = ""; + std::string m_m3uPath; + std::string m_m3uUrl; bool m_cacheM3U = false; int m_startChannelNumber = 1; bool m_numberChannelsByM3uOrderOnly = false; PathType m_epgPathType = PathType::REMOTE_PATH; - std::string m_epgPath = ""; - std::string m_epgUrl = ""; + std::string m_epgPath; + std::string m_epgUrl; bool m_cacheEPG = false; int m_epgTimeShiftMins = 0; bool m_tsOverride = true; bool m_useEpgGenreTextWhenMapping = false; PathType m_genresPathType = PathType::LOCAL_PATH; - std::string m_genresPath = ""; - std::string m_genresUrl = ""; + std::string m_genresPath; + std::string m_genresUrl; PathType m_logoPathType = PathType::REMOTE_PATH; - std::string m_logoPath = ""; - std::string m_logoBaseUrl = ""; + std::string m_logoPath; + std::string m_logoBaseUrl; EpgLogosMode m_epgLogosMode = EpgLogosMode::IGNORE_XMLTV; }; } //namespace iptvsimple diff --git a/src/iptvsimple/data/EpgEntry.cpp b/src/iptvsimple/data/EpgEntry.cpp index 93aeab64a..6ad1124a0 100644 --- a/src/iptvsimple/data/EpgEntry.cpp +++ b/src/iptvsimple/data/EpgEntry.cpp @@ -234,7 +234,7 @@ bool EpgEntry::UpdateFrom(rapidxml::xml_node<>* channelNode, const std::string& if (!episodeNumbersList.empty()) ParseEpisodeNumberInfo(episodeNumbersList); - xml_node<> *creditsNode = channelNode->first_node("credits"); + xml_node<>* creditsNode = channelNode->first_node("credits"); if (creditsNode) { m_cast = GetJoinedNodeValues(creditsNode, "actor"); diff --git a/src/iptvsimple/utilities/FileUtils.cpp b/src/iptvsimple/utilities/FileUtils.cpp index 7bcc2700b..3c0d543bb 100644 --- a/src/iptvsimple/utilities/FileUtils.cpp +++ b/src/iptvsimple/utilities/FileUtils.cpp @@ -195,6 +195,11 @@ bool FileUtils::FileExists(const std::string& file) return XBMC->FileExists(file.c_str(), false); } +bool FileUtils::DeleteFile(const std::string& file) +{ + return XBMC->DeleteFile(file.c_str()); +} + bool FileUtils::CopyFile(const std::string& sourceFile, const std::string& targetFile) { bool copySuccessful = true; diff --git a/src/iptvsimple/utilities/FileUtils.h b/src/iptvsimple/utilities/FileUtils.h index 54df40313..ab09f158d 100644 --- a/src/iptvsimple/utilities/FileUtils.h +++ b/src/iptvsimple/utilities/FileUtils.h @@ -39,6 +39,7 @@ namespace iptvsimple static int GetCachedFileContents(const std::string& cachedName, const std::string& filePath, std::string& content, const bool useCache = false); static bool FileExists(const std::string& file); + static bool DeleteFile(const std::string& file); static bool CopyFile(const std::string& sourceFile, const std::string& targetFile); static bool CopyDirectory(const std::string& sourceDir, const std::string& targetDir, bool recursiveCopy); static std::string GetSystemAddonPath(); diff --git a/src/iptvsimple/utilities/XMLUtils.h b/src/iptvsimple/utilities/XMLUtils.h index 020ea4210..9409e122a 100644 --- a/src/iptvsimple/utilities/XMLUtils.h +++ b/src/iptvsimple/utilities/XMLUtils.h @@ -40,8 +40,7 @@ inline std::string GetJoinedNodeValues(const rapidxml::xml_node* rootNode, c { std::string stringValue; - rapidxml::xml_node* childNode = nullptr; - for (childNode = rootNode->first_node(tag); childNode; childNode = childNode->next_sibling(tag)) + for (rapidxml::xml_node* childNode = rootNode->first_node(tag); childNode; childNode = childNode->next_sibling(tag)) { if (childNode) { @@ -59,8 +58,7 @@ inline std::vector GetNodeValuesList(const rapidxml::xml_node* { std::vector stringValues; - rapidxml::xml_node* childNode = nullptr; - for(childNode = rootNode->first_node(tag); childNode; childNode = childNode->next_sibling(tag)) + for(rapidxml::xml_node* childNode = rootNode->first_node(tag); childNode; childNode = childNode->next_sibling(tag)) { if (childNode) stringValues.emplace_back(childNode->value());