class MMapFile

Provides efficient file I/O by mapping a file into a process address space and copying bytes between the system supplied memory and user buffers

Public Methods

int err ()
status (errno) of last file operation
off_t lseek (off_t offset, int whence)
move read/write file pointer, modeled after lseek(2)
MMapFile (char *fileName, int oflag, int mode = 0664, size_t sizeBuffer = 0x0)
constructor - open the specified file
ssize_t read (void *buf, size_t nbyte)
read 'nbyte' bytes into 'buf'
ssize_t write (const void *buf, size_t nbyte)
write 'nbyte' bytes from 'buf'
~MMapFile ()
destructor - close the file, free all resources

Private Fields

size_t actualSize_
actual size of file
caddr_t curAddr_
current location in buffer
int errno_
last error encountered
int fd_
file descriptor
size_t fileSize_
size of file, which could be larger than actualSize,
caddr_t mapAddr_
mapping address
size_t mapSize_
size of memory map
int mode_
open-ing mode for file
off_t offset_
current offset into file
int oflag_
open-ing oflag for file

Private Methods

void cleanup ()
perform cleanup after error

Documentation

Provides efficient file I/O by mapping a file into a process address space and copying bytes between the system supplied memory and user buffers. (The overhead for memcpy() is small compared to the cost of the read()/write() calls we avoid.)
MMapFile(char *fileName, int oflag, int mode = 0664, size_t sizeBuffer = 0x0)
constructor - open the specified file

~MMapFile()
destructor - close the file, free all resources

int err()
status (errno) of last file operation

ssize_t read(void *buf, size_t nbyte)
read 'nbyte' bytes into 'buf'

ssize_t write(const void *buf, size_t nbyte)
write 'nbyte' bytes from 'buf'

off_t lseek(off_t offset, int whence)
move read/write file pointer, modeled after lseek(2)

void cleanup()
perform cleanup after error

int errno_
last error encountered

int fd_
file descriptor

off_t offset_
current offset into file

caddr_t mapAddr_
mapping address

caddr_t curAddr_
current location in buffer

size_t mapSize_
size of memory map

size_t fileSize_
size of file, which could be larger than actualSize,

size_t actualSize_
actual size of file

int mode_
open-ing mode for file

int oflag_
open-ing oflag for file


This class has no child classes.
See Also:
MMapFileExample

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de