From bce5aef0687beb65b1c26bf04f2b7cecb22d9c4b Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Thu, 27 Apr 2023 16:11:43 +0200 Subject: [PATCH] tvg_saver: fixing file opening mode Opening files in text mode on windows can cause issues. Fixed by changeing the mode to binary. @Issue: https://github.com/thorvg/thorvg/issues/957 @Issue: https://github.com/thorvg/thorvg/issues/1380 --- src/savers/tvg/tvgTvgSaver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/savers/tvg/tvgTvgSaver.cpp b/src/savers/tvg/tvgTvgSaver.cpp index 58790894..10985701 100644 --- a/src/savers/tvg/tvgTvgSaver.cpp +++ b/src/savers/tvg/tvgTvgSaver.cpp @@ -170,7 +170,7 @@ bool TvgSaver::saveEncoding(const std::string& path) memcpy(uncompressed, &compressedSizeBits, TVG_HEADER_COMPRESSED_SIZE_BITS); //Good optimization, flush to file. - auto fp = _fopen(path.c_str(), "w+"); + auto fp = _fopen(path.c_str(), "wb+"); if (!fp) goto fail; //write header @@ -193,7 +193,7 @@ fail: bool TvgSaver::flushTo(const std::string& path) { - auto fp = _fopen(path.c_str(), "w+"); + auto fp = _fopen(path.c_str(), "wb+"); if (!fp) return false; if (fwrite(buffer.data, SIZE(uint8_t), buffer.count, fp) == 0) {