Skip to content

Commit cbc8e1b

Browse files
authored
Merge pull request syoyo#479 from The0Dev/fix_wopen_ronly
Added the pmode argument to _wopen to fix the access permission on MinGW
2 parents 212de90 + 22dfeab commit cbc8e1b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tiny_gltf.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,7 @@ bool WriteWholeFile(std::string *err, const std::string &filepath,
31513151
#ifdef _WIN32
31523152
#if defined(__GLIBCXX__) // mingw
31533153
int file_descriptor = _wopen(UTF8ToWchar(filepath).c_str(),
3154-
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
3154+
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
31553155
__gnu_cxx::stdio_filebuf<char> wfile_buf(
31563156
file_descriptor, std::ios_base::out | std::ios_base::binary);
31573157
std::ostream f(&wfile_buf);
@@ -7127,7 +7127,7 @@ static bool SerializeGltfBufferData(const std::vector<unsigned char> &data,
71277127
#ifdef _WIN32
71287128
#if defined(__GLIBCXX__) // mingw
71297129
int file_descriptor = _wopen(UTF8ToWchar(binFilename).c_str(),
7130-
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
7130+
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
71317131
__gnu_cxx::stdio_filebuf<char> wfile_buf(
71327132
file_descriptor, std::ios_base::out | std::ios_base::binary);
71337133
std::ostream output(&wfile_buf);
@@ -8378,7 +8378,7 @@ static bool WriteGltfFile(const std::string &output,
83788378
std::ofstream gltfFile(UTF8ToWchar(output).c_str());
83798379
#elif defined(__GLIBCXX__)
83808380
int file_descriptor = _wopen(UTF8ToWchar(output).c_str(),
8381-
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
8381+
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
83828382
__gnu_cxx::stdio_filebuf<char> wfile_buf(
83838383
file_descriptor, std::ios_base::out | std::ios_base::binary);
83848384
std::ostream gltfFile(&wfile_buf);
@@ -8463,7 +8463,7 @@ static bool WriteBinaryGltfFile(const std::string &output,
84638463
std::ofstream gltfFile(UTF8ToWchar(output).c_str(), std::ios::binary);
84648464
#elif defined(__GLIBCXX__)
84658465
int file_descriptor = _wopen(UTF8ToWchar(output).c_str(),
8466-
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
8466+
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
84678467
__gnu_cxx::stdio_filebuf<char> wfile_buf(
84688468
file_descriptor, std::ios_base::out | std::ios_base::binary);
84698469
std::ostream gltfFile(&wfile_buf);

0 commit comments

Comments
 (0)