Have get_version check for the file named version first

This commit is contained in:
Howard Hinnant 2017-01-01 15:02:08 -05:00
parent 4a1c49152f
commit 2935f80109

18
tz.cpp
View File

@ -2726,15 +2726,25 @@ static
std::string
get_version(const std::string& path)
{
std::ifstream infile(path + "NEWS");
std::string version;
while (infile)
std::ifstream infile(path + "version");
if (infile.is_open())
{
infile >> version;
if (version == "Release")
if (!infile.fail())
return version;
}
else
{
infile.open(path + "NEWS");
while (infile)
{
infile >> version;
return version;
if (version == "Release")
{
infile >> version;
return version;
}
}
}
throw std::runtime_error("Unable to get Timezone database version from " + path);