- use FileWriter for 'writemidi' CCMD.

This commit is contained in:
Christoph Oelckers 2017-12-02 12:33:58 +01:00
parent 1af42b3d50
commit 8d26760671

View file

@ -803,18 +803,17 @@ CCMD (writemidi)
} }
TArray<uint8_t> midi; TArray<uint8_t> midi;
FILE *f;
bool success; bool success;
static_cast<MIDIStreamer *>(currSong)->CreateSMF(midi, 1); static_cast<MIDIStreamer *>(currSong)->CreateSMF(midi, 1);
f = fopen(argv[1], "wb"); auto f = FileWriter::Open(argv[1]);
if (f == NULL) if (f == NULL)
{ {
Printf("Could not open %s.\n", argv[1]); Printf("Could not open %s.\n", argv[1]);
return; return;
} }
success = (fwrite(&midi[0], 1, midi.Size(), f) == (size_t)midi.Size()); success = (f->Write(&midi[0], midi.Size()) == (size_t)midi.Size());
fclose (f); delete f;
if (!success) if (!success)
{ {