mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
try to abstract out _wsystem and std::system
This commit is contained in:
parent
9112dfd4a7
commit
5db1cbdc8e
1 changed files with 17 additions and 4 deletions
|
@ -37,6 +37,22 @@ std::filesystem::path getExecutablePath()
|
|||
#endif
|
||||
}
|
||||
|
||||
int runBinary(const std::filesystem::path& binaryPath, const std::filesystem::path& iniPath, const std::filesystem::path& cfgPath)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::wstring wBinaryPath = binaryPath.native();
|
||||
std::wstring wIniPath = iniPath.native();
|
||||
std::wstring wCfgPath = cfgPath.native();
|
||||
std::wstringstream cmd;
|
||||
cmd << wBinaryPath << L" -i " << wIniPath << L" -c " << wCfgPath;
|
||||
return _wsystem(cmd.str().c_str());
|
||||
#else
|
||||
std::stringstream cmd;
|
||||
cmd << binaryPath << " -i " << iniPath << " -c " << cfgPath;
|
||||
return std::system(cmd.str().c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
struct TestParam
|
||||
{
|
||||
std::string name;
|
||||
|
@ -65,10 +81,7 @@ Archive 1=game2.bsa
|
|||
std::filesystem::path tempCfgFile = std::filesystem::temp_directory_path() / (param.fileName + ".cfg");
|
||||
std::filesystem::path binaryPath = getExecutablePath() / "openmw-iniimporter";
|
||||
|
||||
std::stringstream cmd;
|
||||
cmd << binaryPath << " -i " << tempIniFile << " -c " << tempCfgFile;
|
||||
|
||||
int ret = std::system(cmd.str().c_str());
|
||||
int ret = runBinary(binaryPath, tempIniFile, tempCfgFile);
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
||||
// Verify the cfg file was created and has the expected contents
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue