mode xml epg delete direct into function

This commit is contained in:
TangoCash
2022-09-09 22:43:15 +02:00
committed by Thilo Graf
parent 108ebe8301
commit 9a4bd22793
2 changed files with 11 additions and 6 deletions

View File

@@ -449,7 +449,7 @@ bool readEventsFromFile(std::string &epgname, int &ev_count)
return true; return true;
} }
bool readEventsFromXMLTV(std::string &epgname, int &ev_count) bool readEventsFromXMLTV(std::string &epgname, int &ev_count, bool delete_after)
{ {
xmlDocPtr event_parser = NULL; xmlDocPtr event_parser = NULL;
xmlNodePtr tv; xmlNodePtr tv;
@@ -563,6 +563,14 @@ bool readEventsFromXMLTV(std::string &epgname, int &ev_count)
} }
xmlFreeDoc(event_parser); xmlFreeDoc(event_parser);
if (delete_after)
{
int ret = unlink(epgname.c_str());
if (ret != 0)
printf("Failed to delete file: %s\n", epgname.c_str());
}
return true; return true;
} }
@@ -712,10 +720,7 @@ void *insertEventsfromXMLTV(void * data)
{ {
if (!access(tmp_name.c_str(), R_OK)) if (!access(tmp_name.c_str(), R_OK))
{ {
readEventsFromXMLTV(tmp_name, ev_count); readEventsFromXMLTV(tmp_name, ev_count, true);
int ret = unlink(tmp_name.c_str());
if (ret != 0)
printf("Failed to delete file: %s\n", tmp_name.c_str());
} }
} }
else else

View File

@@ -37,7 +37,7 @@
void *insertEventsfromFile(void * data); void *insertEventsfromFile(void * data);
void *insertEventsfromXMLTV(void * data); void *insertEventsfromXMLTV(void * data);
bool readEventsFromFile(std::string &epgname, int &ev_count); bool readEventsFromFile(std::string &epgname, int &ev_count);
bool readEventsFromXMLTV(std::string &epgname, int &ev_count); bool readEventsFromXMLTV(std::string &epgname, int &ev_count, bool delete_after = false);
bool readEventsFromDir(std::string &epgdir, int &ev_count); bool readEventsFromDir(std::string &epgdir, int &ev_count);
void writeEventsToFile(const char *epgdir); void writeEventsToFile(const char *epgdir);
t_channel_id getepgid(std::string epg_name); t_channel_id getepgid(std::string epg_name);