Quellcode durchsuchen

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

pull/5481/head
ssszcmawo vor 3 Wochen
committed von GitHub
Ursprung
Commit
c256f146b4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: B5690EEEBB952194
1 geänderte Dateien mit 19 neuen und 9 gelöschten Zeilen
  1. +19
    -9
      src/rcore.c

+ 19
- 9
src/rcore.c Datei anzeigen

@ -3230,15 +3230,25 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName)
#if defined(SUPPORT_AUTOMATION_EVENTS)
// Export events as binary file
// TODO: Save to memory buffer and SaveFileData()
/*
unsigned char fileId[4] = "rAE ";
FILE *raeFile = fopen(fileName, "wb");
fwrite(fileId, sizeof(unsigned char), 4, raeFile);
fwrite(&eventCount, sizeof(int), 1, raeFile);
fwrite(events, sizeof(AutomationEvent), eventCount, raeFile);
fclose(raeFile);
*/
// Binary buffer size = header (file id + count) + events data
int binarySize = 4 + sizeof(int) + sizeof(AutomationEvent)*list.count;
unsigned char *binBuffer = (unsigned char* )RL_MALLOC(binarySize);
if(!binBuffer) return false;
int offset = 0;
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
// NOTE: Save to memory buffer and SaveFileText()

Laden…
Abbrechen
Speichern