unzip.cpp: Fix wrong open mode

By default, std::ofstream objects are opened under the std::ios::out
mode, equivalent to "r" mode in fopen(3), which has non-portable
behaviour. [1]

In order to avoid non-portable behaviour, std::ios::binary must be used
instead, equivalent to "rb" mode in fopen(3).

[1]: https://en.cppreference.com/w/cpp/io/basic_ofstream/basic_ofstream
This commit is contained in:
Xavier Del Campo Romero 2025-01-09 21:54:19 +01:00
parent 53a758688e
commit 1a4dc5f50f
Signed by: xavi
GPG key ID: 84FF3612A9BF43F2

View file

@ -65,7 +65,7 @@ end:
int unzip::extract(const std::string &path) const
{
std::ofstream out(path);
std::ofstream out(path, std::ios::binary);
int ret = -1, error = unzOpenCurrentFile(f);
if (error)