[#BloombergLP-bdls-FilesystemUtil-map]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::xref:BloombergLP/bdls/FilesystemUtil.adoc[FilesystemUtil]::map
:relfileprefix: ../../../
:mrdocs:

Map the region of the specified `size` bytes, starting at the specified `offset` bytes into the file with the specified `descriptor` to memory, and load into the specified `address` of the mapped area&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; The access permissions for mapping memory are defined by the specified `mode`, which may be a combination of `MemoryUtil&colon;&colon;k&lowbar;ACCESS&lowbar;READ`, `MemoryUtil&colon;&colon;k&lowbar;ACCESS&lowbar;WRITE` and `MemoryUtil&colon;&colon;k&lowbar;ACCESS&lowbar;EXECUTE`&period; Note that on failure, the value of `address` is undefined&period; Also note that mapping will succeed even if there are fewer than `offset &plus; size` bytes in the specified file, and an attempt to access the mapped memory beyond the end of the file will result in undefined behavior (i&period;e&period;, this function does not grow the file to guarantee it can accommodate the mapped region)&period; Also note that mapping past the end of file may return 0, but any access of the resulting mapped memory may segfault&period;

== Synopsis

Declared in `&lt;bdls&lowbar;filesystemutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
map(
    xref:BloombergLP/bdls/FilesystemUtil/FileDescriptor.adoc[FileDescriptor] descriptor,
    void** address,
    xref:BloombergLP/bdls/FilesystemUtil/Offset.adoc[Offset] offset,
    std::size&lowbar;t size,
    int mode);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
