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

Map a region of the file with `descriptor`, rejecting past&hyphen;EOF maps&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
mapChecked(
    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);
----

== Description

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, `k&lowbar;ERROR&lowbar;PAST&lowbar;EOF` if an attempt is made to map past the end of file, 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`, though on some platforms they must be a subset of the file permissions&period; The behavior is undefined unless bits in `mode` other than `MemoryUtil&colon;&colon;k&lowbar;ACCESS&lowbar;READ&lowbar;WRITE&lowbar;EXECUTE` are all clear, unless `0 &lt;&equals; offset`, and unless `0 &lt; size`, and unless the `offset` is a multiple of `MemoryUtil&colon;&colon;pageSize()`&period; Note that on failure, the value of `address` is undefined&period; Also note that the check against mapping past the end of file and all assertions are done before the call to map the file&period;

== Return Value

0 on success, `k&lowbar;ERROR&lowbar;PAST&lowbar;EOF` if the region extends past the end of the file, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *descriptor*
| file descriptor of the file to map
| *address*
| receives the base address of the mapped region
| *offset*
| byte offset in the file at which mapping begins
| *size*
| length in bytes of the region to map
| *mode*
| memory access permissions for the mapping
|===


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