|
rlib
Convenience library for useful things
|
Memory-mapped file API. More...
Go to the source code of this file.
Macros | |
| #define | r_mem_file_ref r_ref_ref |
Acquire a new reference to file. | |
| #define | r_mem_file_unref r_ref_unref |
Release a reference to file; unmaps when the last drops. | |
Typedefs | |
| typedef struct RMemFile | RMemFile |
| Opaque handle to a memory-mapped file region. | |
Enumerations | |
| enum | RMemProt { R_MEM_PROT_NONE = 0x0 , R_MEM_PROT_READ = 0x1 , R_MEM_PROT_WRITE = 0x2 , R_MEM_PROT_EXEC = 0x4 } |
| Page-level protection flags for the mapping. More... | |
Functions | |
| RMemFile * | r_mem_file_new (const rchar *file, RMemProt prot, rboolean writeback) |
Map file into memory by pathname. | |
| RMemFile * | r_mem_file_new_from_handle (RIOHandle handle, RMemProt prot, rboolean writeback) |
| Map an already-opened file handle into memory. | |
| rsize | r_mem_file_get_size (RMemFile *file) |
| Size of the mapped region in bytes. | |
| rpointer | r_mem_file_get_mem (RMemFile *file) |
| Pointer to the first byte of the mapped region. | |
Memory-mapped file API.
Thin portability wrapper around mmap on POSIX and CreateFileMapping / MapViewOfFile on Win32. Maps the entire file at construction time; the resulting RMemFile is a refcounted view (use r_mem_file_ref / r_mem_file_unref).
Useful for read-only parsing of file-backed binary formats (ELF, PE, PDF, etc.) where you want a single pointer + length to feed into a streaming parser instead of doing buffered read calls.