From 22dfeab315aaba29981d7645be3afaec1b9817d2 Mon Sep 17 00:00:00 2001 From: TheDev <98645239+The0Dev@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:21:20 +0300 Subject: [PATCH] Added the pmode argument to _wopen to fix the access permission on MinGW --- tiny_gltf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 7ef28f4..303eaad 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -3151,7 +3151,7 @@ bool WriteWholeFile(std::string *err, const std::string &filepath, #ifdef _WIN32 #if defined(__GLIBCXX__) // mingw int file_descriptor = _wopen(UTF8ToWchar(filepath).c_str(), - _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY); + _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE); __gnu_cxx::stdio_filebuf wfile_buf( file_descriptor, std::ios_base::out | std::ios_base::binary); std::ostream f(&wfile_buf); @@ -7127,7 +7127,7 @@ static bool SerializeGltfBufferData(const std::vector &data, #ifdef _WIN32 #if defined(__GLIBCXX__) // mingw int file_descriptor = _wopen(UTF8ToWchar(binFilename).c_str(), - _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY); + _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE); __gnu_cxx::stdio_filebuf wfile_buf( file_descriptor, std::ios_base::out | std::ios_base::binary); std::ostream output(&wfile_buf); @@ -8352,7 +8352,7 @@ static bool WriteGltfFile(const std::string &output, std::ofstream gltfFile(UTF8ToWchar(output).c_str()); #elif defined(__GLIBCXX__) int file_descriptor = _wopen(UTF8ToWchar(output).c_str(), - _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY); + _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE); __gnu_cxx::stdio_filebuf wfile_buf( file_descriptor, std::ios_base::out | std::ios_base::binary); std::ostream gltfFile(&wfile_buf); @@ -8437,7 +8437,7 @@ static bool WriteBinaryGltfFile(const std::string &output, std::ofstream gltfFile(UTF8ToWchar(output).c_str(), std::ios::binary); #elif defined(__GLIBCXX__) int file_descriptor = _wopen(UTF8ToWchar(output).c_str(), - _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY); + _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE); __gnu_cxx::stdio_filebuf wfile_buf( file_descriptor, std::ios_base::out | std::ios_base::binary); std::ostream gltfFile(&wfile_buf);