1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-06 00:40:04 +00:00

give this a try...

This commit is contained in:
Bret Curtis 2023-04-30 18:05:30 +02:00
parent 2ab77691bf
commit 4ae3c217d7
2 changed files with 30 additions and 5 deletions

View File

@ -6,11 +6,8 @@
#include "CLI/CLI.hpp"
#include <components/files/configurationmanager.hpp>
#include <components/files/conversion.hpp>
namespace sfs = std::filesystem;
#ifndef _WIN32
int main(int argc, char* argv[])
{
@ -93,7 +90,6 @@ int wmain(int argc, wchar_t* wargv[])
"\n\twin1252 - Western European (Latin) alphabet, used by default"
)
->default_str("win1252")->check(CLI::IsMember({"win1250", "win1251", "win1252"}, CLI::ignore_case));
;
bool verbose = false;
app.add_flag("-v,--verbose", verbose, "verbose output");

View File

@ -4,6 +4,35 @@
#include <sstream>
#include <vector>
#ifdef _WIN32
#include <windows.h>
#elif defined(__APPLE__)
#include <mach-o/dyld.h>
#else
#include <unistd.h>
#endif
std::filesystem::path getExecutablePath() {
#ifdef _WIN32
WCHAR buffer[MAX_PATH];
GetModuleFileNameW(NULL, buffer, MAX_PATH);
std::wstring exe_path(buffer);
return std::filesystem::path(exe_path).parent_path();
#elif defined(__APPLE__)
char buffer[PATH_MAX];
uint32_t bufsize = sizeof(buffer);
_NSGetExecutablePath(buffer, &bufsize);
return std::filesystem::path(buffer).parent_path();;
#else
char buffer[PATH_MAX];
ssize_t len = ::readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
if (len != -1) {
buffer[len] = '\0';
std::string exe_path(buffer);
return std::filesystem::path(exe_path).parent_path();
#endif
}
struct TestParam
{
std::string name;
@ -30,7 +59,7 @@ Archive 1=game2.bsa
tempFile << iniData;
tempFile.close();
std::filesystem::path tempCfgFile = std::filesystem::temp_directory_path() / (param.fileName + ".cfg");
std::filesystem::path binaryPath = std::filesystem::current_path() / "openmw-iniimporter";
std::filesystem::path binaryPath = getExecutablePath() / "openmw-iniimporter";
std::stringstream cmd;
cmd << binaryPath << " -i " << tempIniFile << " -c " << tempCfgFile;