Skip to content

Commit

Permalink
fix windows compilation (strukturag#1302)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Sep 10, 2024
1 parent 7b7ac8e commit 252ed4a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1413,14 +1413,18 @@ void Box_iloc::set_use_tmp_file(bool flag)
{
m_use_tmpfile = flag;
if (flag) {
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
strcpy(m_tmp_filename, "/tmp/libheif-XXXXXX");
m_tmpfile_fd = mkstemp(m_tmp_filename);
#else
// TODO Currently unused code. Implement when needed.
assert(false);
# if 0
char tmpname[L_tmpnam_s];
// TODO: check return value (errno_t)
tmpnam_s(tmpname, L_tmpnam_s);
_sopen_s(&m_tmpfile_fd, tmpname, _O_CREAT | _O_TEMPORARY | _O_TRUNC | _O_RDWR, _SH_DENYRW, _S_IREAD | _S_IWRITE);
# endif
#endif
}
}
Expand Down Expand Up @@ -1643,10 +1647,14 @@ Error Box_iloc::append_data(heif_item_id item_ID,
extent.length = data.size();

if (m_use_tmpfile && construction_method==0) {
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
ssize_t cnt = ::write(m_tmpfile_fd, data.data(), data.size());
#else
// TODO Currently unused code. Implement when needed.
assert(false);
# if 0
int cnt = _write(m_tmpfile_fd, data.data(), data.size());
# endif
#endif
if (cnt < 0) {
std::stringstream sstr;
Expand Down Expand Up @@ -1904,7 +1912,11 @@ Error Box_iloc::write_mdat_after_iloc(StreamWriter& writer)
#if !defined(_WIN32) && !defined(_WIN64)
ssize_t cnt = ::read(m_tmpfile_fd, data.data(), extent.length);
#else
// TODO Currently unused code. Implement when needed.
assert(false);
# if 0
int cnt = _read(m_tmpfile_fd, data.data(), extent.length);
# endif
#endif
if (cnt<0) {
std::stringstream sstr;
Expand Down

0 comments on commit 252ed4a

Please sign in to comment.