1 /* SPDX-FileCopyrightText: 2020 Blender Authors
3 * SPDX-License-Identifier: GPL-2.0-or-later */
11 #include "BLI_compiler_attrs.h"
12 #include "BLI_utildefines.h"
18 /* Memory-mapped file IO that implements all the OS-specific details and error handling. */
22 typedef struct BLI_mmap_file BLI_mmap_file
;
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
;
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);
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
;
38 void BLI_mmap_free(BLI_mmap_file
*file
) ATTR_NONNULL(1);