added saving to memory buffer and SaveFileData for binary files (#5476)

This commit is contained in:
ssszcmawo
2026-01-07 22:32:58 +01:00
committed by GitHub
parent 23bc037c37
commit c256f146b4

View File

@ -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()