#define RESOURCE_NAME_LEN_MAX 256 /* A resource contains data that can be retrieved globally by name. * If enabled during compilation, resource data is embedded in the * executable. Otherwise each resource represents a file on disk. */ struct resource { struct string _data; b32 _exists; #if RESOURCES_EMBEDDED struct string _name; #else struct sys_file _file; struct sys_file_map _file_map; u8 _name_text[RESOURCE_NAME_LEN_MAX]; u8 _name_len; #endif }; /* ========================== * * Startup * ========================== */ struct resource_startup_receipt { i32 _; }; struct resource_startup_receipt resource_startup(void); /* ========================== * * Open / close * ========================== */ struct resource resource_open(struct string name); #if RESOURCES_EMBEDDED #define resource_close(res_ptr) (UNUSED)res_ptr #else void resource_close(struct resource *res_ptr); #endif /* ========================== * * Data * ========================== */ #define resource_get_data(res_ptr) (res_ptr)->_data #define resource_exists(res_ptr) (res_ptr)->_exists #if RESOURCES_EMBEDDED #define resource_get_name(res_ptr) (res_ptr)->_name #else #define resource_get_name(res_ptr) STRING((res_ptr)->_name_len, (res_ptr)->_name_text) #endif