Class
FileMappingA structure to memory-map a file.
A structure to memory-map a file.
Defined in | <seqan/file.h> |
---|---|
Signature |
template <[typename TSpec]>
struct FileMapping;
|
Template Parameters
TSpec |
The specializing type. Default: void. |
---|
Interface Function Overview
-
bool adviseFileSegment(fileMapping, advise, addr, fileOfs, size);
Give advise about use of a memory-mapped file segment. -
bool cancelFileSegment(fileMapping, addr, beginPos, size);
Cancel all outstanding transactions of a memory-mapped file segment. -
bool close(fileMapping);
Close a file and its memory mapping. -
bool closeAndResize(fileMapping, newFileSize);
Close a memory mapping and resize and close the underlying file. -
bool flushFileSegment(fileMapping, addr, beginPos, size);
Wait for all outstanding transactions of a memory-mapped file segment. -
TSize length(fileMapping);
Return the file size of a memory mapping. -
TPtr mapFileSegment(fileMapping, fileOfs[, size[, mode]]);
Map a segment of a file into memory. -
bool open(fileMapping, fileName[, openMode]);
Open a file to be mapped into memory. -
bool openTemp(fileMapping);
Open a temporary file to be mapped into memory. -
TPtr remapFileSegment(fileMapping, oldAddr, oldFileOfs, oldSize, newSize);
Change the size of a memory-mapped file segment. -
bool resize(fileMapping, newFileSize);
Resize the underlying file. -
bool unmappedFileSegment(fileMapping, addr, size);
Unmap a memory-mapped file segment.
Interface Metafunction Overview
-
Size<TFileMapping>::Type;
Return the size type of the FileMapping.
Detailed Description
This structure represents both a file and its memory mapping.
Interface Functions Detail
bool adviseFileSegment(fileMapping, advise, addr, fileOfs, size);
Give advise about use of a memory-mapped file segment.
Parameters
fileMapping
|
The FileMapping object to adsive segment in. |
---|---|
advise
|
The advise type. Type: FileMappingAdvise. |
addr
|
A pointer t othe beginning of the memory-mapped segment in memory (returned by a prior call of mapFileSegment). |
fileOfs
|
The absolute start address of the segment in bytes. |
size
|
The segment length in bytes. |
Returns
bool |
true on success, false on failure. |
---|
Remarks
This function has no effect on Windows. On all other platforms it calls posix_madvise.
Data Races
Thread safety unknown!
bool cancelFileSegment(fileMapping, addr, beginPos, size);
Cancel all outstanding transactions of a memory-mapped file segment.
Parameters
fileMapping
|
The FileMapping object. |
---|---|
addr
|
A pointer to the beginning of the memory-mapped segment in memory (returned by a prior call of FileMapping#mapFileSegment). |
beginPos
|
the absolute start address of the segment in bytes. |
size
|
The segment length in bytes. |
Returns
bool |
true on success, false on failure. |
---|
Data Races
Thread safety unknown!
bool close(fileMapping);
Close a file and its memory mapping.
Parameters
fileMapping
|
The FileMapping to close |
---|
Returns
bool |
true on success, false otherwise. |
---|
Data Races
Thread safety unknown!
bool closeAndResize(fileMapping, newFileSize);
Close a memory mapping and resize and close the underlying file.
Parameters
fileMapping
|
The FileMapping to close. |
---|---|
newFileSize
|
The size the file should have after closing. |
Returns
bool |
true indicating success, false failure. |
---|
Data Races
Thread safety unknown!
bool flushFileSegment(fileMapping, addr, beginPos, size);
Wait for all outstanding transactions of a memory-mapped file segment.
Parameters
fileMapping
|
A FileMapping object. |
---|---|
addr
|
A pointer to the beginning of memory-mapped segment in memory (returned by a prior call of mapFileSegment. |
beginPos
|
The absolute start address of the segment in bytes. |
size
|
The segment length in bytes. |
Returns
bool |
true on success, false on failure. |
---|
Remarks
This function has no effect under Windows. On all other platforms it calls msync. This function is only needed to synchronize file accesses in non-shared-memory environments.
Data Races
Thread safety unknown!
TSize length(fileMapping);
Return the file size of a memory mapping.
Parameters
fileMapping
|
The FileMapping to return the length for. |
---|
Returns
TSize |
The file size (Metafunction: Size). |
---|
Data Races
Thread safety unknown!
TPtr mapFileSegment(fileMapping, fileOfs[, size[, mode]]);
Map a segment of a file into memory.
Parameters
fileMapping
|
A FileMapping object. |
---|---|
fileOfs
|
The absolute start address of the segment in bytes. |
size
|
The segment length in bytes. |
mode
|
The mapping access mode. Default rread/write open mode of the underlying file. Type: FileMappingMode. |
Returns
TPtr |
A pointer to the beginning of the memory-mapped segment in memory or NULL on error. TPtr is void *. |
---|
Data Races
Thread safety unknown!
bool open(fileMapping, fileName[, openMode]);
Open a file to be mapped into memory.
Parameters
fileMapping
|
The FileMapping to open. |
---|---|
fileName
|
The path to the fie. |
openMode
|
The mode to open the file in, flags from FileOpenMode to combine using OR. Write-only mode is not supported, use OPEN_RDWR if you need write access. If you omit the OPEN_APPEND flag in write mode, the file will be cleared when opened. Default: OPEN_RDWR | OPEN_CREATE | OPEN_APPEND. |
Returns
bool |
true if the opening was successful, false otherwise. |
---|
Data Races
Thread safety unknown!
bool openTemp(fileMapping);
Open a temporary file to be mapped into memory.
Parameters
fileMapping
|
The FileMapping to open using a temporary file. |
---|
Returns
bool |
true on success, false otherwise. |
---|
Data Races
Thread safety unknown!
TPtr remapFileSegment(fileMapping, oldAddr, oldFileOfs, oldSize, newSize);
Change the size of a memory-mapped file segment.
Parameters
fileMapping
|
The FileMapping object. |
---|---|
oldAddr
|
The address returned by mapFileSegment. |
oldFileOfs
|
The fileOfs parameter used in mapFileSegment. |
oldSize
|
The size parameter used in mapFileSegment. |
newSize
|
the new segment length in bytes. |
Returns
TPtr |
A pointer to the beginning of the memory-mapped segment in memory or NULL on error. Type: void*. |
---|
Data Races
Thread safety unknown!
bool resize(fileMapping, newFileSize);
Resize the underlying file.
Parameters
fileMapping
|
The FileMapping to resize. |
---|---|
newFileSize
|
The new file size to set. |
Returns
bool |
true on success, false otherwise. |
---|
Remarks
On Windows, all existing file mappings must be unmapped via unmapFileSegment before claling this function.
Data Races
Thread safety unknown!
bool unmappedFileSegment(fileMapping, addr, size);
Unmap a memory-mapped file segment.
Parameters
fileMapping
|
A FileMapping object. |
---|---|
addr
|
The pointer to the beginning of the memory-mapped segment in memory. Type: void*. |
size
|
The segment length in bytes. |
Returns
bool |
true on success, false on failure. |
---|
Data Races
Thread safety unknown!