Blender V4.3
BLI_mmap.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#include "BLI_compiler_attrs.h"
12#include "BLI_utildefines.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/* Memory-mapped file IO that implements all the OS-specific details and error handling. */
19
20struct BLI_mmap_file;
21
23
24/* Prepares an opened file for memory-mapped IO.
25 * May return NULL if the operation fails.
26 * Note that this seeks to the end of the file to determine its length. */
28
29/* Reads length bytes from file at the given offset into dest.
30 * Returns whether the operation was successful (may fail when reading beyond the file
31 * end or when IO errors occur). */
32bool BLI_mmap_read(BLI_mmap_file *file, void *dest, size_t offset, size_t length)
34
37
39
40#ifdef __cplusplus
41}
42#endif
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_MALLOC
#define ATTR_NONNULL(...)
bool BLI_mmap_read(BLI_mmap_file *file, void *dest, size_t offset, size_t length) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition BLI_mmap.c:182
void * BLI_mmap_get_pointer(BLI_mmap_file *file) ATTR_WARN_UNUSED_RESULT
Definition BLI_mmap.c:211
void BLI_mmap_free(BLI_mmap_file *file) ATTR_NONNULL(1)
Definition BLI_mmap.c:221
BLI_mmap_file * BLI_mmap_open(int fd) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_mmap.c:132
size_t BLI_mmap_get_length(const BLI_mmap_file *file) ATTR_WARN_UNUSED_RESULT
Definition BLI_mmap.c:216