Fixed deprecated library calls

This commit is contained in:
Daniel Wolf 2016-06-26 11:06:44 +02:00
parent 96b0ad9b1d
commit 0aeb35c42e
2 changed files with 6 additions and 3 deletions

View File

@ -164,7 +164,9 @@ void WaveFileReader::openFile() {
file.seekg(0);
}
} catch (const std::ifstream::failure&) {
throw runtime_error(strerror(errno));
char message[256];
strerror_s(message, sizeof message, errno);
throw runtime_error(message);
}
}

View File

@ -11,11 +11,12 @@ string formatDuration(duration<double> seconds) {
}
string formatTime(time_t time, const string& format) {
tm* timeInfo = localtime(&time);
tm timeInfo;
localtime_s(&timeInfo, &time);
std::vector<char> buffer(20);
bool success = false;
while (!success) {
success = strftime(buffer.data(), buffer.size(), format.c_str(), timeInfo) != 0;
success = strftime(buffer.data(), buffer.size(), format.c_str(), &timeInfo) != 0;
if (!success) buffer.resize(buffer.size() * 2);
}
return string(buffer.data());