2011-03-11 19:52:24 +01:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/kos_io.h>
|
|
|
|
|
|
|
|
void *load_file(const char *path, size_t *len)
|
|
|
|
{
|
|
|
|
fileinfo_t info;
|
|
|
|
size_t bytes;
|
|
|
|
void *file = NULL;
|
|
|
|
|
|
|
|
if( len) *len = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if( !get_fileinfo(path, &info) )
|
|
|
|
{
|
|
|
|
|
2013-03-01 07:55:27 +01:00
|
|
|
file = (void*)user_alloc( info.size );
|
2011-03-11 19:52:24 +01:00
|
|
|
read_file(path, file, 0, info.size, &bytes );
|
|
|
|
if( bytes == info.size )
|
|
|
|
{
|
|
|
|
if ( *(uint32_t*)file == 0x4B43504B )
|
|
|
|
{
|
|
|
|
void *tmp = NULL;
|
|
|
|
info.size = ((size_t*)file)[1];
|
2013-03-01 07:55:27 +01:00
|
|
|
tmp = (void*)user_alloc(info.size);
|
2011-03-11 19:52:24 +01:00
|
|
|
unpack(file, tmp);
|
|
|
|
user_free(file);
|
|
|
|
file = tmp;
|
|
|
|
}
|
|
|
|
if(len) *len = info.size;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return file;
|
|
|
|
};
|
|
|
|
|
|
|
|
|