2024-11-10 22:11:29 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-02-26 08:47:09 +01:00
|
|
|
#include <iron_global.h>
|
2024-11-10 22:11:29 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
#define IRON_OUTDIR "out"
|
|
|
|
|
#ifdef IRON_ANDROID
|
2024-11-10 22:11:29 +01:00
|
|
|
struct AAsset;
|
|
|
|
|
struct __sFILE;
|
|
|
|
|
typedef struct __sFILE FILE;
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
#define IRON_FILE_TYPE_ASSET 0
|
|
|
|
|
#define IRON_FILE_TYPE_SAVE 1
|
2024-11-10 22:11:29 +01:00
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
typedef struct iron_file_reader {
|
2024-11-10 22:11:29 +01:00
|
|
|
void *data; // A file handle or a more complex structure
|
|
|
|
|
size_t size;
|
|
|
|
|
size_t offset; // Needed by some implementations
|
|
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
bool (*close)(struct iron_file_reader *reader);
|
|
|
|
|
size_t (*read)(struct iron_file_reader *reader, void *data, size_t size);
|
|
|
|
|
size_t (*pos)(struct iron_file_reader *reader);
|
|
|
|
|
bool (*seek)(struct iron_file_reader *reader, size_t pos);
|
|
|
|
|
} iron_file_reader_t;
|
2024-11-10 22:11:29 +01:00
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
bool iron_file_reader_open(iron_file_reader_t *reader, const char *filepath, int type);
|
|
|
|
|
bool iron_file_reader_close(iron_file_reader_t *reader);
|
|
|
|
|
size_t iron_file_reader_read(iron_file_reader_t *reader, void *data, size_t size);
|
|
|
|
|
size_t iron_file_reader_size(iron_file_reader_t *reader);
|
|
|
|
|
size_t iron_file_reader_pos(iron_file_reader_t *reader);
|
|
|
|
|
bool iron_file_reader_seek(iron_file_reader_t *reader, size_t pos);
|
|
|
|
|
float iron_read_f32le(uint8_t *data);
|
|
|
|
|
float iron_read_f32be(uint8_t *data);
|
|
|
|
|
uint64_t iron_read_u64le(uint8_t *data);
|
|
|
|
|
uint64_t iron_read_u64be(uint8_t *data);
|
|
|
|
|
int64_t iron_read_s64le(uint8_t *data);
|
|
|
|
|
int64_t iron_read_s64be(uint8_t *data);
|
|
|
|
|
uint32_t iron_read_u32le(uint8_t *data);
|
|
|
|
|
uint32_t iron_read_u32be(uint8_t *data);
|
|
|
|
|
int32_t iron_read_s32le(uint8_t *data);
|
|
|
|
|
int32_t iron_read_s32be(uint8_t *data);
|
|
|
|
|
uint16_t iron_read_u16le(uint8_t *data);
|
|
|
|
|
uint16_t iron_read_u16be(uint8_t *data);
|
|
|
|
|
int16_t iron_read_s16le(uint8_t *data);
|
|
|
|
|
int16_t iron_read_s16be(uint8_t *data);
|
|
|
|
|
uint8_t iron_read_u8(uint8_t *data);
|
|
|
|
|
int8_t iron_read_s8(uint8_t *data);
|
2024-11-10 22:11:29 +01:00
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
void iron_internal_set_files_location(char *dir);
|
2025-09-28 19:38:08 +02:00
|
|
|
char *iron_internal_files_location(void);
|
2025-03-09 17:02:12 +01:00
|
|
|
bool iron_internal_file_reader_open(iron_file_reader_t *reader, const char *filename, int type);
|
2024-11-10 22:11:29 +01:00
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
typedef struct iron_file_writer {
|
2025-02-26 08:47:09 +01:00
|
|
|
void *file;
|
|
|
|
|
const char *filename;
|
2025-03-09 17:02:12 +01:00
|
|
|
} iron_file_writer_t;
|
2025-02-26 08:47:09 +01:00
|
|
|
|
2025-03-09 17:02:12 +01:00
|
|
|
bool iron_file_writer_open(iron_file_writer_t *writer, const char *filepath);
|
|
|
|
|
void iron_file_writer_write(iron_file_writer_t *writer, void *data, int size);
|
|
|
|
|
void iron_file_writer_close(iron_file_writer_t *writer);
|