1 #include "version.hpp"
2 
3 #include <boost/filesystem/path.hpp>
4 #include <boost/filesystem/fstream.hpp>
5 
6 namespace Version
7 {
8 
getOpenmwVersion(const std::string & resourcePath)9 Version getOpenmwVersion(const std::string &resourcePath)
10 {
11     boost::filesystem::path path (resourcePath + "/version");
12 
13     boost::filesystem::ifstream stream (path);
14 
15     Version v;
16     std::getline(stream, v.mVersion);
17     std::getline(stream, v.mCommitHash);
18     std::getline(stream, v.mTagHash);
19     return v;
20 }
21 
describe()22 std::string Version::describe()
23 {
24     std::string str = "OpenMW version " + mVersion;
25     std::string rev = mCommitHash;
26     if (!rev.empty())
27     {
28         rev = rev.substr(0, 10);
29         str += "\nRevision: " + rev;
30     }
31     return str;
32 }
33 
getOpenmwVersionDescription(const std::string & resourcePath)34 std::string getOpenmwVersionDescription(const std::string &resourcePath)
35 {
36     Version v = getOpenmwVersion(resourcePath);
37     return v.describe();
38 }
39 
40 }
41