skip if file size is changing

This commit is contained in:
hummypkg 2017-03-09 15:22:22 +00:00 committed by HummyPkg
parent 792ac397f4
commit 2ffb32bcb4
1 changed files with 21 additions and 12 deletions

33
file.c
View File

@ -23,7 +23,27 @@ struct epg *
open_file(char *filename)
{
struct epg *epg;
struct stat st;
struct stat st, st2;
if (debug)
printf("Opening file '%s'\n", filename);
if (stat(filename, &st) == -1)
{
perror(filename);
return NULL;
}
sleep(1);
if (stat(filename, &st2) == -1)
{
perror(filename);
return NULL;
}
if (st.st_size != st2.st_size)
{
printf("EPG data file is updating, try later.\n");
return NULL;
}
if (!(epg = malloc(sizeof(struct epg))))
{
@ -31,18 +51,7 @@ open_file(char *filename)
return NULL;
}
if (debug)
printf("Opening file '%s'\n", filename);
strcpy(epg->fname, filename);
if (stat(epg->fname, &st) == -1)
{
perror(epg->fname);
free(epg);
return NULL;
}
epg->binsize = st.st_size;
if (debug)