fix: separate types of std::string in Packwiz
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
dff5fea976
commit
d35c2db41e
@ -22,10 +22,14 @@
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
|
||||
#include <toml++/toml.h>
|
||||
#include "FileSystem.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "minecraft/mod/Mod.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
|
||||
#include <toml++/toml.h>
|
||||
|
||||
namespace Packwiz {
|
||||
|
||||
auto getRealIndexName(QDir& index_dir, QString normalized_fname, bool should_find_match) -> QString
|
||||
@ -63,22 +67,22 @@ static inline auto indexFileName(QString const& mod_slug) -> QString
|
||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||
|
||||
// Helper functions for extracting data from the TOML file
|
||||
auto stringEntry(toml::table table, const std::string entry_name) -> QString
|
||||
auto stringEntry(toml::table table, QString entry_name) -> QString
|
||||
{
|
||||
auto node = table[entry_name];
|
||||
auto node = table[StringUtils::toStdString(entry_name)];
|
||||
if (!node) {
|
||||
qCritical() << QString::fromStdString("Failed to read str property '" + entry_name + "' in mod metadata.");
|
||||
qCritical() << "Failed to read str property '" + entry_name + "' in mod metadata.";
|
||||
return {};
|
||||
}
|
||||
|
||||
return QString::fromStdString(node.value_or(""));
|
||||
return node.value_or("");
|
||||
}
|
||||
|
||||
auto intEntry(toml::table table, const std::string entry_name) -> int
|
||||
auto intEntry(toml::table table, QString entry_name) -> int
|
||||
{
|
||||
auto node = table[entry_name];
|
||||
auto node = table[StringUtils::toStdString(entry_name)];
|
||||
if (!node) {
|
||||
qCritical() << QString::fromStdString("Failed to read int property '" + entry_name + "' in mod metadata.");
|
||||
qCritical() << "Failed to read int property '" + entry_name + "' in mod metadata.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -145,6 +149,8 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
|
||||
// they want to do!
|
||||
if (index_file.exists()) {
|
||||
index_file.remove();
|
||||
} else {
|
||||
FS::ensureFilePathExists(index_file.fileName());
|
||||
}
|
||||
|
||||
if (!index_file.open(QIODevice::ReadWrite)) {
|
||||
@ -228,14 +234,14 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
|
||||
toml::table table;
|
||||
#if TOML_EXCEPTIONS
|
||||
try {
|
||||
table = toml::parse_file(index_dir.absoluteFilePath(real_fname).toStdString());
|
||||
table = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname)));
|
||||
} catch (const toml::parse_error& err) {
|
||||
qWarning() << QString("Could not open file %1!").arg(normalized_fname);
|
||||
qWarning() << "Reason: " << QString(err.what());
|
||||
return {};
|
||||
}
|
||||
#else
|
||||
table = toml::parse_file(index_dir.absoluteFilePath(real_fname).toStdString());
|
||||
table = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname)));
|
||||
if (!table) {
|
||||
qWarning() << QString("Could not open file %1!").arg(normalized_fname);
|
||||
qWarning() << "Reason: " << QString(table.error().what());
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
|
||||
struct toml_table_t;
|
||||
class QDir;
|
||||
|
||||
// Mod from launcher/minecraft/mod/Mod.h
|
||||
@ -34,9 +33,6 @@ namespace Packwiz {
|
||||
|
||||
auto getRealIndexName(QDir& index_dir, QString normalized_index_name, bool should_match = false) -> QString;
|
||||
|
||||
auto stringEntry(toml_table_t* parent, const char* entry_name) -> QString;
|
||||
auto intEntry(toml_table_t* parent, const char* entry_name) -> int;
|
||||
|
||||
class V1 {
|
||||
public:
|
||||
struct Mod {
|
||||
|
Loading…
Reference in New Issue
Block a user