Blender
V4.3
source
blender
blenlib
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
15
extern
"C"
{
16
#endif
17
18
/* Memory-mapped file IO that implements all the OS-specific details and error handling. */
19
20
struct
BLI_mmap_file
;
21
22
typedef
struct
BLI_mmap_file
BLI_mmap_file
;
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. */
27
BLI_mmap_file
*
BLI_mmap_open
(
int
fd)
ATTR_MALLOC
ATTR_WARN_UNUSED_RESULT
;
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). */
32
bool
BLI_mmap_read
(
BLI_mmap_file
*file,
void
*dest,
size_t
offset,
size_t
length)
33
ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL
(1);
34
35
void
*
BLI_mmap_get_pointer
(
BLI_mmap_file
*file)
ATTR_WARN_UNUSED_RESULT
;
36
size_t
BLI_mmap_get_length
(
const
BLI_mmap_file
*file)
ATTR_WARN_UNUSED_RESULT
;
37
38
void
BLI_mmap_free
(
BLI_mmap_file
*file)
ATTR_NONNULL
(1);
39
40
#ifdef __cplusplus
41
}
42
#endif
BLI_compiler_attrs.h
ATTR_WARN_UNUSED_RESULT
#define ATTR_WARN_UNUSED_RESULT
Definition
BLI_compiler_attrs.h:15
ATTR_MALLOC
#define ATTR_MALLOC
Definition
BLI_compiler_attrs.h:46
ATTR_NONNULL
#define ATTR_NONNULL(...)
Definition
BLI_compiler_attrs.h:25
BLI_mmap_read
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
BLI_mmap_get_pointer
void * BLI_mmap_get_pointer(BLI_mmap_file *file) ATTR_WARN_UNUSED_RESULT
Definition
BLI_mmap.c:211
BLI_mmap_free
void BLI_mmap_free(BLI_mmap_file *file) ATTR_NONNULL(1)
Definition
BLI_mmap.c:221
BLI_mmap_open
BLI_mmap_file * BLI_mmap_open(int fd) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition
BLI_mmap.c:132
BLI_mmap_get_length
size_t BLI_mmap_get_length(const BLI_mmap_file *file) ATTR_WARN_UNUSED_RESULT
Definition
BLI_mmap.c:216
BLI_utildefines.h
BLI_mmap_file
Definition
BLI_mmap.c:26
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0