mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-18 13:41:26 +01:00
added saving to memory buffer and SaveFileData for binary files (#5476)
This commit is contained in:
28
src/rcore.c
28
src/rcore.c
@ -3230,15 +3230,25 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName)
|
|||||||
|
|
||||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||||
// Export events as binary file
|
// Export events as binary file
|
||||||
// TODO: Save to memory buffer and SaveFileData()
|
|
||||||
/*
|
// Binary buffer size = header (file id + count) + events data
|
||||||
unsigned char fileId[4] = "rAE ";
|
int binarySize = 4 + sizeof(int) + sizeof(AutomationEvent)*list.count;
|
||||||
FILE *raeFile = fopen(fileName, "wb");
|
unsigned char *binBuffer = (unsigned char* )RL_MALLOC(binarySize);
|
||||||
fwrite(fileId, sizeof(unsigned char), 4, raeFile);
|
if(!binBuffer) return false;
|
||||||
fwrite(&eventCount, sizeof(int), 1, raeFile);
|
|
||||||
fwrite(events, sizeof(AutomationEvent), eventCount, raeFile);
|
int offset = 0;
|
||||||
fclose(raeFile);
|
memcpy(binBuffer + offset, "rAE ", 4); offset += 4;
|
||||||
*/
|
memcpy(binBuffer + offset, &list.count, sizeof(int)); offset += sizeof(int);
|
||||||
|
|
||||||
|
if(list.count > 0)
|
||||||
|
{
|
||||||
|
memcpy(binBuffer + offset, list.events,sizeof(AutomationEvent)*list.count);
|
||||||
|
offset += sizeof(AutomationEvent)*list.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
success = SaveFileData(TextFormat("%s.rae",fileName), binBuffer, binarySize);
|
||||||
|
|
||||||
|
RL_FREE(binBuffer);
|
||||||
|
|
||||||
// Export events as text
|
// Export events as text
|
||||||
// NOTE: Save to memory buffer and SaveFileText()
|
// NOTE: Save to memory buffer and SaveFileText()
|
||||||
|
|||||||
Reference in New Issue
Block a user