mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-05 20:45:07 +01:00
Store the WUPS version a plugin was compiled with inside the MetaInformation
This commit is contained in:
parent
36e99e95a2
commit
553d887526
@ -9,4 +9,5 @@ PluginMetaInformation::PluginMetaInformation(const PluginMetaInformation &other)
|
|||||||
this->description = other.description;
|
this->description = other.description;
|
||||||
this->size = other.size;
|
this->size = other.size;
|
||||||
this->storageId = other.storageId;
|
this->storageId = other.storageId;
|
||||||
|
this->wupsversion = other.wupsversion;
|
||||||
}
|
}
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "WUPSVersion.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -48,6 +49,10 @@ public:
|
|||||||
return this->description;
|
return this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] const WUPSVersion &getWUPSVersion() const {
|
||||||
|
return this->wupsversion;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getStorageId() const {
|
[[nodiscard]] const std::string &getStorageId() const {
|
||||||
return this->storageId;
|
return this->storageId;
|
||||||
}
|
}
|
||||||
@ -83,6 +88,14 @@ private:
|
|||||||
this->description = std::move(_description);
|
this->description = std::move(_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setWUPSVersion(uint16_t major, uint16_t minor, uint16_t revision) {
|
||||||
|
this->wupsversion = WUPSVersion(major, minor, revision);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWUPSVersion(WUPSVersion &_wupsversion) {
|
||||||
|
this->wupsversion = _wupsversion;
|
||||||
|
}
|
||||||
|
|
||||||
void setSize(size_t _size) {
|
void setSize(size_t _size) {
|
||||||
this->size = _size;
|
this->size = _size;
|
||||||
}
|
}
|
||||||
@ -99,6 +112,7 @@ private:
|
|||||||
std::string description;
|
std::string description;
|
||||||
std::string storageId;
|
std::string storageId;
|
||||||
size_t size{};
|
size_t size{};
|
||||||
|
WUPSVersion wupsversion = WUPSVersion(0, 0, 0);
|
||||||
|
|
||||||
friend class PluginMetaInformationFactory;
|
friend class PluginMetaInformationFactory;
|
||||||
|
|
||||||
|
@ -103,7 +103,9 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
|
|||||||
} else if (key == "storage_id") {
|
} else if (key == "storage_id") {
|
||||||
pluginInfo->setStorageId(value);
|
pluginInfo->setStorageId(value);
|
||||||
} else if (key == "wups") {
|
} else if (key == "wups") {
|
||||||
if (value != "0.7.1") {
|
if (value == "0.7.1") {
|
||||||
|
pluginInfo->setWUPSVersion(0, 7, 1);
|
||||||
|
} else {
|
||||||
error = PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION;
|
error = PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
|
DEBUG_FUNCTION_LINE_ERR("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
49
source/plugin/WUPSVersion.h
Normal file
49
source/plugin/WUPSVersion.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "utils/StringTools.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
class WUPSVersion {
|
||||||
|
public:
|
||||||
|
WUPSVersion(int major, int minor, int revision)
|
||||||
|
: mVersion((static_cast<uint64_t>(major) << 32) |
|
||||||
|
(static_cast<uint64_t>(minor) << 16) |
|
||||||
|
static_cast<uint64_t>(revision)) {}
|
||||||
|
|
||||||
|
WUPSVersion(const WUPSVersion &other) = default;
|
||||||
|
|
||||||
|
static std::optional<WUPSVersion> createFromString(const std::string &versionStr) {
|
||||||
|
char *end;
|
||||||
|
errno = 0; // Initialize errno before calling strtol
|
||||||
|
|
||||||
|
auto major = strtol(versionStr.c_str(), &end, 10);
|
||||||
|
if (errno || *end != '.') {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto minor = strtol(end + 1, &end, 10);
|
||||||
|
if (errno || *end != '.') {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto revision = strtol(end + 1, &end, 10);
|
||||||
|
if (errno || *end != '\0') {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WUPSVersion(static_cast<int>(major), static_cast<int>(minor), static_cast<int>(revision));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::strong_ordering operator<=>(const WUPSVersion &other) const {
|
||||||
|
return mVersion <=> other.mVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] std::string toString() const {
|
||||||
|
return string_format("%d.%d.%d", static_cast<int>((mVersion >> 32) & 0xFFFF),
|
||||||
|
static_cast<int>((mVersion >> 16) & 0xFFFF),
|
||||||
|
static_cast<int>((mVersion) &0xFFFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t mVersion{};
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user