fid_Mappedfile Struct Reference
[File handling routines]

Representation of a memory mapped file. More...


Detailed Description

Representation of a memory mapped file.

Among others, this structure bundles the file name, a file descriptor, and the pointer returned by mmap() to the file content. The protection and flags argument passed to mmap() are also stored for re-mapping.

Additionally, this structure allows the use of a memory mapped file as a dynamically growing array. The current size of real data is stored in fid_Mappedfile::occupied, whereas the allocated disk space is stored in fid_Mappedfile::allocated. Whenever fid_Mappedfile::occupied exceeds fid_Mappedfile::allocated, enlarge the file, re-map, and continue.

To support the use of allocated dynamic arrays as mapped files, the concept of fake mapped files has been implemented. Fake mapped files do not have a valid file descriptor, but point to allocated memory. Most functions defined on the fid_Mappedfile structure, however, do not work for fake mapped files, so their use is somewhat limited. Their main purpose is to enable existing code written for reading from memory mapped files to read from allocated memory. A fake mapped file can be identified by using the macro fid_MAPPEDFILE_IS_FAKED() on a fid_Mappedfile structure pointer.

Definition at line 50 of file fileutils.h.

#include <fileutils.h>


Data Fields

unsigned char * content
 Memory mapped file content.
size_t occupied
 Number of bytes used in file.
size_t allocated
 Allocated number of bytes in file.
int fd
 File descriptor as returned by open().
char * filename
 Name of the file in file system, mainly used for diagnostic messages.
int mmap_prot
 Protection flags as passed to last call of mmap() for this file; used or modified for mapping the file again at some later point.
int mmap_flags
 Other flags as passed to last call of mmap() for this file.


Field Documentation

unsigned char* fid_Mappedfile::content

File descriptor as returned by open().

Definition at line 55 of file fileutils.h.

Referenced by fid_file_cleanup(), fid_file_fake(), fid_file_grow_by_size(), fid_file_make_readonly(), and fid_file_unmap().

Name of the file in file system, mainly used for diagnostic messages.

Definition at line 56 of file fileutils.h.

Referenced by fid_file_cleanup(), fid_file_ensure_free_space(), fid_file_fake(), fid_file_grow_by_size(), fid_file_make_readonly(), and fid_file_unmap().

Protection flags as passed to last call of mmap() for this file; used or modified for mapping the file again at some later point.

Definition at line 58 of file fileutils.h.

Referenced by fid_file_fake(), fid_file_grow_by_size(), and fid_file_make_readonly().

Other flags as passed to last call of mmap() for this file.

See also:
fid_Mappedfile::mmap_prot.

Definition at line 61 of file fileutils.h.

Referenced by fid_file_fake(), fid_file_grow_by_size(), and fid_file_make_readonly().


Generated on Wed Jul 8 17:21:18 2009 for Full-text Index Data structure library by  doxygen 1.5.9