#include <data.h>
List of all members.
Detailed Description
Definition at line 36 of file data.h.
Constructor & Destructor Documentation
| cFileMap::cFileMap |
( |
const char * |
Filename, |
|
|
bool |
Rw |
|
) |
| |
Definition at line 41 of file data.c.
{
filename=strdup(Filename);
rw=Rw;
fd=-1; count=len=0; addr=0; failed=false;
}
Definition at line 48 of file data.c.
References free.
{
Clean();
free(filename);
}
| cFileMap::cFileMap |
( |
const char * |
Filename, |
|
|
bool |
Rw |
|
) |
| |
Member Function Documentation
| unsigned char* cFileMap::Addr |
( |
void |
| ) |
const [inline] |
| unsigned char* cFileMap::Addr |
( |
void |
| ) |
const [inline] |
| bool cFileMap::IsFileMap |
( |
const char * |
Name, |
|
|
bool |
Rw |
|
) |
| |
| bool cFileMap::IsFileMap |
( |
const char * |
Name, |
|
|
bool |
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;
}
return false;
}
| bool cFileMap::Map |
( |
void |
| ) |
|
| int cFileMap::Size |
( |
void |
| ) |
const [inline] |
| int cFileMap::Size |
( |
void |
| ) |
const [inline] |
| void cFileMap::Sync |
( |
void |
| ) |
|
| void cFileMap::Sync |
( |
void |
| ) |
|
| bool cFileMap::Unmap |
( |
void |
| ) |
|
| bool cFileMap::Unmap |
( |
void |
| ) |
|
The documentation for this class was generated from the following files: