mirror of https://github.com/OpenMW/openmw.git
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.
39 lines
872 B
C++
39 lines
872 B
C++
#include "version.hpp"
|
|
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
namespace Version
|
|
{
|
|
|
|
Version getOpenmwVersion(const std::filesystem::path& resourcePath)
|
|
{
|
|
std::ifstream stream(resourcePath / "version");
|
|
|
|
Version v;
|
|
std::getline(stream, v.mVersion);
|
|
std::getline(stream, v.mCommitHash);
|
|
std::getline(stream, v.mTagHash);
|
|
return v;
|
|
}
|
|
|
|
std::string Version::describe() const
|
|
{
|
|
std::string str = "OpenMW version " + mVersion;
|
|
std::string rev = mCommitHash;
|
|
if (!rev.empty())
|
|
{
|
|
rev = rev.substr(0, 10);
|
|
str += "\nRevision: " + rev;
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string getOpenmwVersionDescription(const std::filesystem::path& resourcePath)
|
|
{
|
|
Version v = getOpenmwVersion(resourcePath);
|
|
return v.describe();
|
|
}
|
|
|
|
}
|