rtengine/include/fio.h
Kevin Trogant 1dba3d2d63 fix, feat: various issues
- [win32] FIO thread no longer hangs during application exit
- Signal if a file operation was actually successfull.
- Add a logging function (currently identical to vyReportError)
2023-10-13 23:15:23 +02:00

61 lines
1.1 KiB
C

#ifndef VY_FIO_H
#define VY_FIO_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "voyage.h"
enum
{
VY_FILE_BUFFER_FLAG_FILE_NOT_FOUND = 0x1,
VY_FILE_BUFFER_FLAG_READ_FAILED = 0x2,
};
typedef struct {
void *data;
size_t size;
uint32_t flags;
} vy_file_buffer;
inline bool vyWasFileBufferSuccessful(const vy_file_buffer *fb) {
return fb->flags == 0;
}
/* used to identify a file (XXH3 hash of the path) */
typedef uint64_t vy_file_id;
typedef unsigned int vy_fio_handle;
typedef struct {
unsigned int queue_size;
unsigned int max_file_count;
} vy_fio_config;
bool vyInitFIO(const vy_fio_config *config);
void vyShutdownFIO(void);
vy_file_id vyGetFileId(const char *path);
vy_file_id vyGetFileIdFromSpan(vy_text_span path);
vy_file_id vyAddFile(const char *path);
vy_file_id vyAddFileFromSpan(vy_text_span path);
const char *vyGetFilePath(vy_file_id fid);
vy_fio_handle vyEnqueueRead(vy_file_id fid);
void vyAbortFIO(vy_fio_handle fio);
bool vyIsFIOFinished(vy_fio_handle fio);
bool vyRetrieveReadBuffer(vy_fio_handle fio, vy_file_buffer *buffer);
void vyFreeFileBuffer(vy_file_buffer buffer);
#endif