pr_createfilemap.rst (1441B)
1 PR_CreateFileMap 2 ================ 3 4 Creates a file mapping object. 5 6 7 Syntax 8 ------ 9 10 .. code:: 11 12 #include <prio.h> 13 14 PRFileMap* PR_CreateFileMap( 15 PRFileDesc *fd, 16 PRInt64 size, 17 PRFileMapProtect prot); 18 19 20 Parameters 21 ~~~~~~~~~~ 22 23 The function has the following parameters: 24 25 ``fd`` 26 A pointer to a :ref:`PRFileDesc` object representing the file that is to 27 be mapped to memory. 28 ``size`` 29 Size of the file specified by ``fd``. 30 ``prot`` 31 Protection option for read and write accesses of a file mapping. This 32 parameter consists of one of the following options: 33 34 - :ref:`PR_PROT_READONLY`. Read-only access. 35 - :ref:`PR_PROT_READWRITE`. Readable, and write is shared. 36 - :ref:`PR_PROT_WRITECOPY`. Readable, and write is private 37 (copy-on-write). 38 39 40 Returns 41 ~~~~~~~ 42 43 - If successful, a file mapping of type :ref:`PRFileMap`. 44 - If unsuccessful, ``NULL``. 45 46 47 Description 48 ----------- 49 50 The ``PRFileMapProtect`` enumeration used in the ``prot`` parameter is 51 defined as follows: 52 53 .. code:: 54 55 typedef enum PRFileMapProtect { 56 PR_PROT_READONLY, 57 PR_PROT_READWRITE, 58 PR_PROT_WRITECOPY 59 } PRFileMapProtect; 60 61 :ref:`PR_CreateFileMap` only prepares for the mapping a file to memory. The 62 returned file-mapping object must be passed to :ref:`PR_MemMap` to actually 63 map a section of the file to memory. 64 65 The file-mapping object should be closed with a :ref:`PR_CloseFileMap` call 66 when it is no longer needed.