Browse Source

skip if file size is changing

master
hummypkg 4 years ago
committed by HummyPkg
parent
commit
2ffb32bcb4
  1. 31
      file.c

31
file.c

@ -23,26 +23,35 @@ struct epg *
open_file(char *filename)
{
struct epg *epg;
struct stat st;
if (!(epg = malloc(sizeof(struct epg))))
{
perror("malloc");
return NULL;
}
struct stat st, st2;
if (debug)
printf("Opening file '%s'\n", filename);
strcpy(epg->fname, 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 (stat(epg->fname, &st) == -1)
if (!(epg = malloc(sizeof(struct epg))))
{
perror(epg->fname);
free(epg);
perror("malloc");
return NULL;
}
strcpy(epg->fname, filename);
epg->binsize = st.st_size;
if (debug)

Loading…
Cancel
Save