2015-07-18 01:01:06 +00:00
|
|
|
#include "version.hpp"
|
|
|
|
|
2022-05-24 21:18:21 +00:00
|
|
|
#include <filesystem>
|
|
|
|
#include <fstream>
|
2015-07-18 01:01:06 +00:00
|
|
|
|
|
|
|
namespace Version
|
|
|
|
{
|
|
|
|
|
2022-06-19 11:28:33 +00:00
|
|
|
Version getOpenmwVersion(const std::filesystem::path& resourcePath)
|
2015-07-18 01:01:06 +00:00
|
|
|
{
|
2022-06-19 11:28:33 +00:00
|
|
|
std::ifstream stream(resourcePath / "version");
|
2015-07-18 01:01:06 +00:00
|
|
|
|
|
|
|
Version v;
|
|
|
|
std::getline(stream, v.mVersion);
|
|
|
|
std::getline(stream, v.mCommitHash);
|
|
|
|
std::getline(stream, v.mTagHash);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2022-07-02 22:02:29 +00:00
|
|
|
std::string Version::describe() const
|
2015-07-18 01:01:06 +00:00
|
|
|
{
|
|
|
|
std::string str = "OpenMW version " + mVersion;
|
|
|
|
std::string rev = mCommitHash;
|
2017-03-05 18:28:29 +00:00
|
|
|
if (!rev.empty())
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2015-07-18 01:01:06 +00:00
|
|
|
rev = rev.substr(0, 10);
|
|
|
|
str += "\nRevision: " + rev;
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2015-07-18 01:01:06 +00:00
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2022-06-19 11:28:33 +00:00
|
|
|
std::string getOpenmwVersionDescription(const std::filesystem::path& resourcePath)
|
2015-07-18 01:01:06 +00:00
|
|
|
{
|
|
|
|
Version v = getOpenmwVersion(resourcePath);
|
|
|
|
return v.describe();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|