summaryrefslogtreecommitdiff
path: root/parse.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2014-04-17 20:30:03 +0200
committerJochen Dolze <vdr@dolze.de>2014-04-17 20:30:03 +0200
commitd45bad06f58853f69dde50d5014addf500fcf61a (patch)
tree0b2f60ef703f585e52916bc1cdae9be86279815e /parse.cpp
parentf6d2648de086186d24a5a0c685b76bb53f106c25 (diff)
downloadvdr-plugin-xmltv2vdr-d45bad06f58853f69dde50d5014addf500fcf61a.tar.gz
vdr-plugin-xmltv2vdr-d45bad06f58853f69dde50d5014addf500fcf61a.tar.bz2
Changed directory handling in FetchSeasonEpisode
Diffstat (limited to 'parse.cpp')
-rw-r--r--parse.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/parse.cpp b/parse.cpp
index 51e98fa..4aa1993 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -181,7 +181,7 @@ bool cParse::FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const cha
DIR *dir=opendir(EPDir);
if (!dir) return false;
struct dirent dirent_buf,*dirent;
- bool found=false;
+ char *fTitle=NULL;
for (;;)
{
if (readdir_r(dir,&dirent_buf,&dirent)!=0) break;
@@ -197,12 +197,14 @@ bool cParse::FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const cha
{
if (Title[dlen]==32)
{
- found=true;
+ if (fTitle) free(fTitle);
+ fTitle=strdup(dirent->d_name);
}
}
else
{
- found=true;
+ if (fTitle) free(fTitle);
+ fTitle=strdup(dirent->d_name);
break;
}
}
@@ -239,7 +241,7 @@ bool cParse::FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const cha
}
}
- if (!found)
+ if (!fTitle)
{
if ((f_season>0) && (f_episode>0))
{
@@ -256,12 +258,17 @@ bool cParse::FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const cha
}
char *epfile=NULL;
- if (asprintf(&epfile,"%s/%s.episodes",EPDir,dirent->d_name)==-1) return false;
+ if (asprintf(&epfile,"%s/%s.episodes",EPDir,fTitle)==-1)
+ {
+ free(fTitle);
+ return false;
+ }
FILE *f=fopen(epfile,"r");
if (!f)
{
free(epfile);
+ free(fTitle);
return false;
}
@@ -289,7 +296,8 @@ bool cParse::FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const cha
dname[0]=0;
}
- if (dname[0]==0) strn0cpy(dname,dirent->d_name,sizeof(dname)-1);
+ if (dname[0]==0) strn0cpy(dname,fTitle,sizeof(dname)-1);
+ free(fTitle);
if (EPTitle && strcasecmp(Title,dname)) *EPTitle=strdup(dname);
@@ -345,7 +353,7 @@ bool cParse::FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const cha
char *line=NULL;
size_t length;
- found=false;
+ bool found=false;
if (EPShortText) *EPShortText=NULL;
size_t charlen=0;
while (getline(&line,&length,f)!=-1)