diff options
author | 2023-09-05 21:39:09 +0000 | |
---|---|---|
committer | 2023-09-08 20:21:00 +0000 | |
commit | 7930f2f2481e7abe6d894717cd78e0e295af54ce (patch) | |
tree | 273fc903e1ca48000d224fe8b4ff11206b858aa0 /tools/aapt/ZipEntry.cpp | |
parent | b2348adbb8137214baca45a338de7219d8528f4b (diff) |
Use localtime_r() on Windows too.
I don't know why I didn't clean these up when I learned about this
trick.
Test: treehugger
Change-Id: Iec74cab28c782a61ef3e48210f3a48043e981212
Diffstat (limited to 'tools/aapt/ZipEntry.cpp')
-rw-r--r-- | tools/aapt/ZipEntry.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/tools/aapt/ZipEntry.cpp b/tools/aapt/ZipEntry.cpp index 5339285f5667..6886993fbfa1 100644 --- a/tools/aapt/ZipEntry.cpp +++ b/tools/aapt/ZipEntry.cpp @@ -18,6 +18,8 @@ // Access to entries in a Zip archive. // +#define _POSIX_THREAD_SAFE_FUNCTIONS // For mingw localtime_r(). + #define LOG_TAG "zip" #include "ZipEntry.h" @@ -337,39 +339,26 @@ time_t ZipEntry::getModWhen(void) const /* * Set the CDE/LFH timestamp from UNIX time. */ -void ZipEntry::setModWhen(time_t when) -{ -#if !defined(_WIN32) - struct tm tmResult; -#endif - time_t even; - unsigned short zdate, ztime; - - struct tm* ptm; - +void ZipEntry::setModWhen(time_t when) { /* round up to an even number of seconds */ - even = (time_t)(((unsigned long)(when) + 1) & (~1)); + time_t even = (time_t)(((unsigned long)(when) + 1) & (~1)); /* expand */ -#if !defined(_WIN32) - ptm = localtime_r(&even, &tmResult); -#else - ptm = localtime(&even); -#endif + struct tm tmResult; + struct tm* ptm = localtime_r(&even, &tmResult); int year; year = ptm->tm_year; if (year < 80) year = 80; - 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; + unsigned short zdate = (year - 80) << 9 | (ptm->tm_mon + 1) << 5 | ptm->tm_mday; + unsigned short ztime = ptm->tm_hour << 11 | ptm->tm_min << 5 | ptm->tm_sec >> 1; mCDE.mLastModFileTime = mLFH.mLastModFileTime = ztime; mCDE.mLastModFileDate = mLFH.mLastModFileDate = zdate; } - /* * =========================================================================== * ZipEntry::LocalFileHeader |