#ifndef VY_FIO_H #define VY_FIO_H #include #include #include #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