SysSecureTryReturnResult(NID_IO, ret == 0, __ConvertNativeErrorToResult(errno),
"Failed to get attributes for directory entry (%s), errno: %d (%s)", pEntryPath.get(), errno, strerror(errno));
- struct tm* pTm = localtime(&statbuf.st_mtime);
- SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno));
+ struct tm resultTm;
+ struct tm* pTm = localtime_r(&statbuf.st_mtime, &resultTm);
+ SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to get local time (%s).", strerror(errno));
DateTime dateTime;
r = dateTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
// attributes
attr = statbuf.st_mode;
- pTm = localtime(&statbuf.st_mtime);
- SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno));
+ struct tm resultTm;
+ pTm = localtime_r(&statbuf.st_mtime, &resultTm);
+ SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to get local time (%s).", strerror(errno));
r = dateTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
SysTryReturn(NID_IO, (!IsFailed(r)), r, r, "[%s] Failed to set DateTime.", GetErrorMessage(r));
- pTm = localtime(&statbuf.st_mtime);
- SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno));
+ pTm = localtime_r(&statbuf.st_mtime, &resultTm);
+ SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to get local time (%s).", strerror(errno));
r = modifiedTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
SysTryReturn(NID_IO, (!IsFailed(r)), r, r, "[%s] Failed to set DateTime.", GetErrorMessage(r));