31 if (!
ELEM(header[7],
'_',
'-') || !
ELEM(header[8],
'v',
'V')) {
35 if (!isdigit(header[9]) || !isdigit(header[10]) || !isdigit(header[11])) {
45 memcpy(num, header + 9, 3);
47 return atoi(num) >= 250;
52 return header[7] ==
'_' ? 4 : 8;
65 uint32_t *bottom = top + ((y - 1) * x);
70 memcpy(line, top, x *
sizeof(
uint32_t));
71 memcpy(top, bottom, x *
sizeof(
uint32_t));
72 memcpy(bottom, line, x *
sizeof(
uint32_t));
82 memcpy(&data, bytes, 4);
91 return (file->read(file, buf, buf_len) == buf_len);
96 if (file->seek !=
nullptr) {
97 if (file->seek(file,
len, SEEK_CUR) == -1) {
104 constexpr size_t dummy_data_size = 4096;
107 const size_t len_chunk = std::min(
len, dummy_data_size);
108 if (
size_t(file->read(file, dummy_data.
data(), len_chunk)) != len_chunk) {
118 const size_t bhead_size,
123 while (
file_read(file, bhead_data, bhead_size)) {
131 switch (*((
int32_t *)bhead_data)) {
132 case MAKE_ID(
'T',
'E',
'S',
'T'): {
134 if (!
file_read(file, shape,
sizeof(shape))) {
141 size_t data_size = block_size -
sizeof(shape);
143 if (thumb->
width < 0 || thumb->
height < 0 || data_size != expected_size) {
153 case MAKE_ID(
'R',
'E',
'N',
'D'): {
175 if (rawfile->
read(rawfile, header,
sizeof(header)) !=
sizeof(header)) {
176 rawfile->
close(rawfile);
181 rawfile->
seek(rawfile, 0, SEEK_SET);
191 if (file !=
nullptr) {
197 if (file !=
nullptr) {
203 if (rawfile !=
nullptr) {
204 rawfile->
close(rawfile);
207 if (file ==
nullptr) {
212 if (file->read(file, header,
sizeof(header)) !=
sizeof(header)) {
#define BLI_array_alloca(arr, realsize)
BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_NONNULL(1)
File and directory operations.
bool BLI_file_magic_is_gzip(const char header[4])
bool BLI_file_magic_is_zstd(const char header[4])
Wrapper for reading from various sources (e.g. raw files, compressed files, memory....
FileReader * BLI_filereader_new_zstd(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FileReader * BLI_filereader_new_gzip(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_kdtree_nd_ free(KDTree *tree)
int bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
#define MAKE_ID(a, b, c, d)
static void endian_switch(uint8_t *ptr, int type_size)
unsigned __int64 uint64_t
blender::Array< uint8_t > data