aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorghost <andreas.monzner@multimedia-labs.de>2010-11-04 17:25:52 +0100
committerghost <andreas.monzner@multimedia-labs.de>2010-11-04 17:25:52 +0100
commite4d1d550d6f1a7d1d75e4524d367a8820b119926 (patch)
treef7bff4d9a0be9df865cd0d548ace0296070683dd
parentf7af4f251d28b270925a98c7f258659a0b3b0c3b (diff)
parent7709c1d61e799fa06a257f1d6b9c23ae205fe0c9 (diff)
downloadenigma2-e4d1d550d6f1a7d1d75e4524d367a8820b119926.tar.gz
enigma2-e4d1d550d6f1a7d1d75e4524d367a8820b119926.zip
Merge branch 'master' into 3.0
-rw-r--r--lib/dvb/epgcache.cpp73
-rw-r--r--lib/dvb/epgcache.h1
2 files changed, 39 insertions, 35 deletions
diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp
index 119223a3..2b688c29 100644
--- a/lib/dvb/epgcache.cpp
+++ b/lib/dvb/epgcache.cpp
@@ -232,6 +232,30 @@ eEPGCache::eEPGCache()
timeUpdated();
}
instance=this;
+
+ memset(m_filename, 0, sizeof(m_filename));
+
+ FILE *f = fopen("/etc/enigma2/epg.dat.src", "r");
+ if (f)
+ {
+ int rd = fread(m_filename, 1, 255, f);
+ if (rd > 0)
+ {
+ m_filename[rd] = 0;
+ char *p=strchr(m_filename, '\n');
+ if (p)
+ m_filename[p-m_filename] = 0;
+ p=strchr(m_filename, '\t');
+ if (p)
+ m_filename[p-m_filename] = 0;
+ }
+ fclose(f);
+ }
+
+ if (!strlen(m_filename))
+ strcpy(m_filename, "/hdd/epg.dat");
+
+ eDebug("[EPGC] read/write epg data from/to '%s'", m_filename);
}
void eEPGCache::timeUpdated()
@@ -962,30 +986,13 @@ void eEPGCache::thread()
void eEPGCache::load()
{
- FILE *f = fopen("/hdd/epg.dat", "r");
+ FILE *f = fopen(m_filename, "r");
if (f)
{
- unlink("/hdd/epg.dat");
+ unlink(m_filename);
int size=0;
int cnt=0;
-#if 0
- unsigned char md5_saved[16];
- unsigned char md5[16];
- bool md5ok=false;
- if (!md5_file("/hdd/epg.dat", 1, md5))
- {
- FILE *f = fopen("/hdd/epg.dat.md5", "r");
- if (f)
- {
- fread( md5_saved, 16, 1, f);
- fclose(f);
- if ( !memcmp(md5_saved, md5, 16) )
- md5ok=true;
- }
- }
- if ( md5ok )
-#endif
{
unsigned int magic=0;
fread( &magic, sizeof(int), 1, f);
@@ -1027,7 +1034,7 @@ void eEPGCache::load()
eventDB[key]=std::pair<eventMap,timeMap>(evMap,tmMap);
}
eventData::load(f);
- eDebug("[EPGC] %d events read from /hdd/epg.dat", cnt);
+ eDebug("[EPGC] %d events read from %s", cnt, m_filename);
#ifdef ENABLE_PRIVATE_EPG
char text2[11];
fread( text2, 11, 1, f);
@@ -1075,9 +1082,15 @@ void eEPGCache::load()
void eEPGCache::save()
{
+ char *buf = realpath(m_filename, NULL);
+ if (!buf)
+ return;
+
+ eDebug("[EPGC] store epg to '%s'", buf);
+
struct statfs s;
off64_t tmp;
- if (statfs("/hdd", &s)<0)
+ if (statfs(buf, &s)<0)
tmp=0;
else
{
@@ -1085,6 +1098,8 @@ void eEPGCache::save()
tmp*=s.f_bsize;
}
+ free(buf);
+
// prevent writes to builtin flash
if ( tmp < 1024*1024*50 ) // storage size < 50MB
return;
@@ -1095,7 +1110,7 @@ void eEPGCache::save()
if ( tmp < (eventData::CacheSize*12)/10 ) // 20% overhead
return;
- FILE *f = fopen("/hdd/epg.dat", "w");
+ FILE *f = fopen(m_filename, "w");
int cnt=0;
if ( f )
{
@@ -1120,7 +1135,7 @@ void eEPGCache::save()
++cnt;
}
}
- eDebug("[EPGC] %d events written to /hdd/epg.dat", cnt);
+ eDebug("[EPGC] %d events written to %s", cnt, m_filename);
eventData::save(f);
#ifdef ENABLE_PRIVATE_EPG
const char* text3 = "PRIVATE_EPG";
@@ -1154,18 +1169,6 @@ void eEPGCache::save()
fseek(f, sizeof(int), SEEK_SET);
fwrite("ENIGMA_EPG_V7", 13, 1, f);
fclose(f);
-#if 0
- unsigned char md5[16];
- if (!md5_file("/hdd/epg.dat", 1, md5))
- {
- FILE *f = fopen("/hdd/epg.dat.md5", "w");
- if (f)
- {
- fwrite( md5, 16, 1, f);
- fclose(f);
- }
- }
-#endif
}
}
diff --git a/lib/dvb/epgcache.h b/lib/dvb/epgcache.h
index 4d45d87e..dca05a52 100644
--- a/lib/dvb/epgcache.h
+++ b/lib/dvb/epgcache.h
@@ -290,6 +290,7 @@ private:
void thread(); // thread function
// called from epgcache thread
+ char m_filename[1024];
void save();
void load();
#ifdef ENABLE_PRIVATE_EPG