|
|
@ -64,7 +64,7 @@ static int logTypeExit = LOG_ERROR; // Log type that exits |
|
|
|
static TraceLogCallback logCallback = NULL; // Log callback function pointer |
|
|
|
|
|
|
|
#if defined(PLATFORM_ANDROID) |
|
|
|
static AAssetManager *assetManager = NULL; // Android assets manager pointer |
|
|
|
static AAssetManager *assetManager = NULL; // Android assets manager pointer |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(PLATFORM_UWP) |
|
|
@ -163,6 +163,54 @@ void TraceLog(int logType, const char *text, ...) |
|
|
|
#endif // SUPPORT_TRACELOG |
|
|
|
} |
|
|
|
|
|
|
|
// Load data from file into a buffer |
|
|
|
unsigned char *LoadFileData(const char *fileName, int *bytesRead) |
|
|
|
{ |
|
|
|
unsigned char *data = NULL; |
|
|
|
*bytesRead = 0; |
|
|
|
|
|
|
|
FILE *file = fopen(fileName, "rb"); |
|
|
|
|
|
|
|
if (file != NULL) |
|
|
|
{ |
|
|
|
fseek(file, 0, SEEK_END); |
|
|
|
int size = ftell(file); |
|
|
|
fseek(file, 0, SEEK_SET); |
|
|
|
|
|
|
|
if (size > 0) |
|
|
|
{ |
|
|
|
data = (unsigned char *)RL_MALLOC(sizeof(unsigned char)*size); |
|
|
|
int count = fread(data, sizeof(unsigned char), size, file); |
|
|
|
*bytesRead = count; |
|
|
|
|
|
|
|
if (count != size) TRACELOG(LOG_WARNING, "[%s] File partially read", fileName); |
|
|
|
} |
|
|
|
else TRACELOG(LOG_WARNING, "[%s] File could not be read", fileName); |
|
|
|
|
|
|
|
fclose(file); |
|
|
|
} |
|
|
|
else TRACELOG(LOG_WARNING, "[%s] File could not be opened", fileName); |
|
|
|
|
|
|
|
return data; |
|
|
|
} |
|
|
|
|
|
|
|
// Save data to file from buffer |
|
|
|
void SaveFileData(const char *fileName, void *data, int bytesToWrite) |
|
|
|
{ |
|
|
|
FILE *file = fopen(fileName, "wb"); |
|
|
|
|
|
|
|
if (file != NULL) |
|
|
|
{ |
|
|
|
int count = fwrite(data, sizeof(unsigned char), bytesToWrite, file); |
|
|
|
|
|
|
|
if (count == 0) TRACELOG(LOG_WARNING, "[%s] File could not be written", fileName); |
|
|
|
else if (count != bytesToWrite) TRACELOG(LOG_WARNING, "[%s] File partially written", fileName); |
|
|
|
|
|
|
|
fclose(file); |
|
|
|
} |
|
|
|
else TRACELOG(LOG_WARNING, "[%s] File could not be opened", fileName); |
|
|
|
} |
|
|
|
|
|
|
|
#if defined(PLATFORM_ANDROID) |
|
|
|
// Initialize asset manager from android app |
|
|
|
void InitAssetManager(AAssetManager *manager) |
|
|
|