|
SASC-NG
DVBSoftCAM
|
#include <data.h>
Inheritance diagram for cFileMap:Public Member Functions | |
| cFileMap (const char *Filename, bool Rw) | |
| ~cFileMap () | |
| bool | Map (void) |
| bool | Unmap (void) |
| void | Sync (void) |
| int | Size (void) const |
| unsigned char * | Addr (void) const |
| bool | IsFileMap (const char *Name, bool Rw) |
| cFileMap::cFileMap | ( | const char * | Filename, |
| bool | Rw | ||
| ) |
| cFileMap::~cFileMap | ( | ) |
| unsigned char* cFileMap::Addr | ( | void | ) | const [inline] |
Definition at line 53 of file data.h.
Referenced by cMapEeprom::cMapEeprom(), cMapRom::cMapRom(), cSeca2ProvSSE::CWT1(), cSeca2Prov::MT(), cSystemFakeNDS::ProcessECM(), cSeca2ProvSSE::SSEPT1(), cSeca2ProvSSE::SSEPT2(), cSeca2ProvSSE::SSET1(), and cSeca2ProvSSE::SSET2().
{ return addr; }
| bool cFileMap::IsFileMap | ( | const char * | Name, |
| bool | Rw | ||
| ) |
Definition at line 54 of file data.c.
Referenced by cFileMaps::GetFileMap().
{
return (!strcmp(Name,filename) && (!Rw || rw));
}
| bool cFileMap::Map | ( | void | ) |
Definition at line 65 of file data.c.
References count, fd, L_GEN_ERROR, open(), and PRINTF.
Referenced by cMapEeprom::cMapEeprom(), cMapRom::cMapRom(), and cSeca2Prov::GetMap().
{
cMutexLock lock(this);
if(addr) { count++; return true; }
if(!failed) {
struct stat64 ds;
if(!stat64(filename,&ds)) {
if(S_ISREG(ds.st_mode)) {
fd=open(filename,rw ? O_RDWR : O_RDONLY);
if(fd>=0) {
unsigned char *map=(unsigned char *)mmap(0,ds.st_size,rw ? (PROT_READ|PROT_WRITE):(PROT_READ),MAP_SHARED,fd,0);
if(map!=MAP_FAILED) {
addr=map; len=ds.st_size; count=1;
return true;
}
else PRINTF(L_GEN_ERROR,"mapping failed on %s: %s",filename,strerror(errno));
close(fd); fd=-1;
}
else PRINTF(L_GEN_ERROR,"error opening filemap %s: %s",filename,strerror(errno));
}
else PRINTF(L_GEN_ERROR,"filemap %s is not a regular file",filename);
}
else PRINTF(L_GEN_ERROR,"can't stat filemap %s: %s",filename,strerror(errno));
failed=true; // don't try this one over and over again
}
return false;
}
| int cFileMap::Size | ( | void | ) | const [inline] |
Definition at line 52 of file data.h.
Referenced by cMapEeprom::cMapEeprom(), cMapRom::cMapRom(), and cSeca2Prov::GetMap().
{ return len; }
| void cFileMap::Sync | ( | void | ) |
Definition at line 103 of file data.c.
Referenced by Unmap().
{
cMutexLock lock(this);
if(addr) msync(addr,len,MS_ASYNC);
}
| bool cFileMap::Unmap | ( | void | ) |
Definition at line 93 of file data.c.
Referenced by cSeca2Prov::GetMap(), cMapEeprom::~cMapEeprom(), cMapRom::~cMapRom(), cSeca2Prov::~cSeca2Prov(), cSeca2ProvSSE::~cSeca2ProvSSE(), and cSystemFakeNDS::~cSystemFakeNDS().
{
cMutexLock lock(this);
if(addr) {
if(!(--count)) { Clean(); return true; }
else Sync();
}
return false;
}