mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 17:56:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			50 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#include <components/version/version.hpp>
 | 
						|
 | 
						|
#include <filesystem>
 | 
						|
#include <fstream>
 | 
						|
 | 
						|
namespace Version
 | 
						|
{
 | 
						|
    std::string_view getVersion()
 | 
						|
    {
 | 
						|
        return "@OPENMW_VERSION@";
 | 
						|
    }
 | 
						|
 | 
						|
    std::string_view getCommitHash()
 | 
						|
    {
 | 
						|
        return "@OPENMW_VERSION_COMMITHASH@";
 | 
						|
    }
 | 
						|
 | 
						|
    std::string_view getTagHash()
 | 
						|
    {
 | 
						|
        return "@OPENMW_VERSION_TAGHASH@";
 | 
						|
    }
 | 
						|
 | 
						|
    int getLuaApiRevision()
 | 
						|
    {
 | 
						|
        return @OPENMW_LUA_API_REVISION@;
 | 
						|
    }
 | 
						|
 | 
						|
    std::string getOpenmwVersionDescription()
 | 
						|
    {
 | 
						|
        std::string str = "OpenMW version ";
 | 
						|
        str += getVersion();
 | 
						|
        if (!getCommitHash().empty())
 | 
						|
        {
 | 
						|
            str += "\nRevision: ";
 | 
						|
            str += getCommitHash().substr(0, 10);
 | 
						|
        }
 | 
						|
        return str;
 | 
						|
    }
 | 
						|
 | 
						|
    bool checkResourcesVersion(const std::filesystem::path& resourcePath)
 | 
						|
    {
 | 
						|
        std::ifstream stream(resourcePath / "version");
 | 
						|
        std::string version, commitHash, tagHash;
 | 
						|
        std::getline(stream, version);
 | 
						|
        std::getline(stream, commitHash);
 | 
						|
        std::getline(stream, tagHash);
 | 
						|
        return getVersion() == version && getCommitHash() == commitHash && getTagHash() == tagHash;
 | 
						|
    }
 | 
						|
 | 
						|
}
 |