auto formated = std::chrono::system_clock::to_time_t(now);
std::stringstream ss;
- ss << std::put_time(std::localtime(&formated), "%Y%m%d-%H%M%S") << ".png";
+ tm time, *ret;
+ ret = localtime_r(&formated, &time);
+ if (ret)
+ ss << std::put_time(&time, "%Y%m%d-%H%M%S") << ".png";
+ else
+ ss << "screenshot.png";
+
return ss.str();
}
bool Dlog::start()
{
int closingFd[2] = { -1, -1 };
+ char buf[2048];
if (pipe(closingFd) == -1) {
- ERROR("failed to create pipes (%s)", strerror(errno));
+ ERROR("failed to create pipes (%s)", strerror_r(errno, buf, sizeof(buf)));
return false;
}
auto const dlogFilePath = "/opt/usr/home/owner/media/Documents/qe9fh483fb4i3fb8we3_universal_switch_dlog.txt";
int dlogFile = open(dlogFilePath, O_RDONLY);
if (dlogFile < 0) {
- ERROR("failed to open file '%s' (%s)", dlogFilePath, strerror(errno));
+ ERROR("failed to open file '%s' (%s)", dlogFilePath, strerror_r(errno, buf, sizeof(buf)));
return false;
}
std::vector<char> tmp(1024 * 128);
std::string line;
size_t pos = 0;
+ char buf[2048];
while (true)
{
ASSERT(pos + 1024 <= tmp.size());
auto count = read(dlogFile, tmp.data() + pos, 1024);
if (count < 0) {
- ERROR("failed to read from pipe (%s)", strerror(errno));
+ ERROR("failed to read from pipe (%s)", strerror_r(errno, buf, sizeof(buf)));
break;
} else if (count == 0) {
- ERROR("other side has close the pipe (%s)", strerror(errno));
+ ERROR("other side has close the pipe (%s)", strerror_r(errno, buf, sizeof(buf)));
break;
}
{