Skip to content

Commit

Permalink
compat: fix 32bit time issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsura authored and BareosBot committed Oct 18, 2023
1 parent c3b5a22 commit 6fea852
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions core/src/win32/compat/compat.cc
Expand Up @@ -761,7 +761,12 @@ static time_t CvtFtimeToUtime(const FILETIME& time)
mstime -= WIN32_FILETIME_ADJUST;
mstime /= WIN32_FILETIME_SCALE; /* convert to seconds. */

return (time_t)(mstime & 0xffffffff);
if constexpr (sizeof(time_t) < sizeof(mstime)) {
// take care of 32bit time_ts (i.e. on 32bit windows)
return static_cast<time_t>(mstime & 0xffff'ffff);
} else {
return static_cast<time_t>(mstime);
}
}

static time_t CvtFtimeToUtime(const LARGE_INTEGER& time)
Expand All @@ -774,7 +779,12 @@ static time_t CvtFtimeToUtime(const LARGE_INTEGER& time)
mstime -= WIN32_FILETIME_ADJUST;
mstime /= WIN32_FILETIME_SCALE; /* convert to seconds. */

return (time_t)(mstime & 0xffffffff);
if constexpr (sizeof(time_t) < sizeof(mstime)) {
// take care of 32bit time_ts (i.e. on 32bit windows)
return static_cast<time_t>(mstime & 0xffff'ffff);
} else {
return static_cast<time_t>(mstime);
}
}

bool CreateJunction(const char* szJunction, const char* szPath)
Expand Down

0 comments on commit 6fea852

Please sign in to comment.