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. |
unsigned char* fid_Mappedfile::content |
Memory mapped file content.
Definition at line 52 of file fileutils.h.
Referenced by fid_alphabet_init_from_specfile(), fid_alphabet_write_to_file(), fid_create_online_files(), fid_file_cleanup(), fid_file_dump_to_file(), fid_file_ensure_free_space(), fid_file_fake(), fid_file_grow_by_size(), fid_file_make_readonly(), fid_file_prefetch(), fid_file_unmap(), fid_file_write(), fid_projectfile_parse_from_file(), fid_sequences_compute_distribution(), fid_sequences_init(), fid_sequences_iterate_range(), fid_sequences_map(), fid_sequences_realize(), fid_suffixarray_compute_distribution(), fid_suffixarray_dump(), fid_suffixarray_dump_suffix(), fid_suffixarray_find_embedded_interval(), fid_suffixarray_find_large_lcp(), fid_suffixarray_get_intervals(), fid_suffixarray_init(), fid_suffixarray_suffix_length(), fid_suffixinterval_dump(), and fid_suffixinterval_homepos().
size_t fid_Mappedfile::occupied |
Number of bytes used in file.
Definition at line 53 of file fileutils.h.
Referenced by fid_alphabet_init_from_specfile(), fid_alphabet_write_to_file(), fid_file_cleanup(), fid_file_dump_to_file(), fid_file_ensure_free_space(), fid_file_fake(), fid_file_grow_by_size(), fid_file_make_readonly(), fid_file_prefetch(), fid_file_unmap(), fid_file_write(), fid_projectfile_parse_from_file(), fid_sequences_compute_distribution(), fid_sequences_realize(), and fid_suffixarray_compute_distribution().
size_t fid_Mappedfile::allocated |
Allocated number of bytes in file.
Definition at line 54 of file fileutils.h.
Referenced by fid_alphabet_write_to_file(), fid_file_cleanup(), fid_file_ensure_free_space(), fid_file_fake(), fid_file_grow_by_size(), fid_file_make_readonly(), and fid_file_unmap().
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().
char* fid_Mappedfile::filename |
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.
Definition at line 61 of file fileutils.h.
Referenced by fid_file_fake(), fid_file_grow_by_size(), and fid_file_make_readonly().