Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b029978 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Use localtime_r() on Windows too." into main am: 2462269f

parents a5b2b5d6 2462269f
Loading
Loading
Loading
Loading
+7 −16
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@
// Access to entries in a Zip archive.
// Access to entries in a Zip archive.
//
//


#define _POSIX_THREAD_SAFE_FUNCTIONS  // For mingw localtime_r().

#define LOG_TAG "zip"
#define LOG_TAG "zip"


#include "ZipEntry.h"
#include "ZipEntry.h"
@@ -354,31 +356,20 @@ time_t ZipEntry::getModWhen(void) const
 */
 */
void ZipEntry::setModWhen(time_t when)
void ZipEntry::setModWhen(time_t when)
{
{
#if !defined(_WIN32)
    struct tm tmResult;
#endif
    time_t even;
    uint16_t zdate, ztime;

    struct tm* ptm;

    /* round up to an even number of seconds */
    /* round up to an even number of seconds */
    even = (when & 1) ? (when + 1) : when;
    time_t even = (when & 1) ? (when + 1) : when;


    /* expand */
    /* expand */
#if !defined(_WIN32)
    struct tm tmResult;
    ptm = localtime_r(&even, &tmResult);
    struct tm* ptm = localtime_r(&even, &tmResult);
#else
    ptm = localtime(&even);
#endif


    int year;
    int year;
    year = ptm->tm_year;
    year = ptm->tm_year;
    if (year < 80)
    if (year < 80)
        year = 80;
        year = 80;


    zdate = (year - 80) << 9 | (ptm->tm_mon+1) << 5 | ptm->tm_mday;
    uint16_t zdate = (year - 80) << 9 | (ptm->tm_mon+1) << 5 | ptm->tm_mday;
    ztime = ptm->tm_hour << 11 | ptm->tm_min << 5 | ptm->tm_sec >> 1;
    uint16_t ztime = ptm->tm_hour << 11 | ptm->tm_min << 5 | ptm->tm_sec >> 1;


    mCDE.mLastModFileTime = mLFH.mLastModFileTime = ztime;
    mCDE.mLastModFileTime = mLFH.mLastModFileTime = ztime;
    mCDE.mLastModFileDate = mLFH.mLastModFileDate = zdate;
    mCDE.mLastModFileDate = mLFH.mLastModFileDate = zdate;