From 58594e255485a6bc2db6b5c3cc7731c8f20d21e0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 16 Jan 2023 22:57:03 +0100 Subject: [PATCH] Fix SMF read/write when compiled on Windows --- libs/evoral/SMF.cc | 4 ++-- libs/evoral/SMFReader.cc | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/evoral/SMF.cc b/libs/evoral/SMF.cc index 54ac07ac2e..6889073bf3 100644 --- a/libs/evoral/SMF.cc +++ b/libs/evoral/SMF.cc @@ -260,7 +260,7 @@ SMF::create(const std::string& path, int track, uint16_t ppqn) { /* put a stub file on disk */ - FILE* f = g_fopen (path.c_str(), "w+"); + FILE* f = g_fopen (path.c_str(), "wb+"); if (f == 0) { return -1; } @@ -513,7 +513,7 @@ SMF::end_write(string const & path) return; } - FILE* f = g_fopen (path.c_str(), "w+"); + FILE* f = g_fopen (path.c_str(), "wb+"); if (f == 0) { throw FileError (path); } diff --git a/libs/evoral/SMFReader.cc b/libs/evoral/SMFReader.cc index 601cd7ac60..d207ccf328 100644 --- a/libs/evoral/SMFReader.cc +++ b/libs/evoral/SMFReader.cc @@ -20,6 +20,8 @@ #include #include #include + +#include #include #include "evoral/midi_util.h" @@ -57,7 +59,7 @@ SMFReader::open(const string& filename) throw (logic_error, UnsupportedTime) cout << "Opening SMF file " << filename << " for reading." << endl; - _fd = fopen(filename.c_str(), "r+"); + _fd = g_fopen(filename.c_str(), "rb+"); if (_fd) { // Read type (bytes 8..9)