forked from teamnwah/openmw-tes3coop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
888 B
C++
42 lines
888 B
C++
#include "version.hpp"
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
#include <boost/filesystem/fstream.hpp>
|
|
|
|
namespace Version
|
|
{
|
|
|
|
Version getOpenmwVersion(const std::string &resourcePath)
|
|
{
|
|
boost::filesystem::path path (resourcePath + "/version");
|
|
|
|
boost::filesystem::ifstream stream (path);
|
|
|
|
Version v;
|
|
std::getline(stream, v.mVersion);
|
|
std::getline(stream, v.mCommitHash);
|
|
std::getline(stream, v.mTagHash);
|
|
return v;
|
|
}
|
|
|
|
std::string Version::describe()
|
|
{
|
|
std::string str = "OpenMW version " + mVersion;
|
|
std::string rev = mCommitHash;
|
|
std::string tag = mTagHash;
|
|
if (!rev.empty() && !tag.empty())
|
|
{
|
|
rev = rev.substr(0, 10);
|
|
str += "\nRevision: " + rev;
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string getOpenmwVersionDescription(const std::string &resourcePath)
|
|
{
|
|
Version v = getOpenmwVersion(resourcePath);
|
|
return v.describe();
|
|
}
|
|
|
|
}
|