Fixed Windows build when using MSVC 14.26 and MacOS build.

crashfix_debugdraw
Project579 3 years ago
parent 6bf4c7a04f
commit 864112b5db

@ -19,9 +19,9 @@ struct Arguments
{ {
std::string mode; std::string mode;
std::filesystem::path filename; std::filesystem::path filename;
std::string extractfile; std::filesystem::path extractfile;
std::string addfile; std::filesystem::path addfile;
std::string outdir; std::filesystem::path outdir;
bool longformat; bool longformat;
bool fullpath; bool fullpath;
@ -115,10 +115,10 @@ bool parseOptions (int argc, char** argv, Arguments &info)
} }
auto inputFiles = variables["input-file"].as< std::vector<Files::MaybeQuotedPath> >(); auto inputFiles = variables["input-file"].as< std::vector<Files::MaybeQuotedPath> >();
info.filename = inputFiles[0]; info.filename = inputFiles[0].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
// Default output to the working directory // Default output to the working directory
info.outdir = "."; info.outdir = std::filesystem::current_path();
if (info.mode == "extract") if (info.mode == "extract")
{ {
@ -129,9 +129,9 @@ bool parseOptions (int argc, char** argv, Arguments &info)
return false; return false;
} }
if (inputFiles.size() > 1) if (inputFiles.size() > 1)
info.extractfile = inputFiles[1]; info.extractfile = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
if (inputFiles.size() > 2) if (inputFiles.size() > 2)
info.outdir = inputFiles[2]; info.outdir = inputFiles[2].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
} }
else if (info.mode == "add") else if (info.mode == "add")
{ {
@ -142,10 +142,10 @@ bool parseOptions (int argc, char** argv, Arguments &info)
return false; return false;
} }
if (inputFiles.size() > 1) if (inputFiles.size() > 1)
info.addfile = inputFiles[1]; info.addfile = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
} }
else if (inputFiles.size() > 1) else if (inputFiles.size() > 1)
info.outdir = inputFiles[1]; info.outdir = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
info.longformat = variables.count("long") != 0; info.longformat = variables.count("long") != 0;
info.fullpath = variables.count("full-path") != 0; info.fullpath = variables.count("full-path") != 0;
@ -179,10 +179,10 @@ int list(std::unique_ptr<File>& bsa, Arguments& info)
template<typename File> template<typename File>
int extract(std::unique_ptr<File>& bsa, Arguments& info) int extract(std::unique_ptr<File>& bsa, Arguments& info)
{ {
std::string archivePath = info.extractfile; std::string archivePath = info.extractfile.string(); //TODO(Project579): This will probably break in windows with unicode paths
Misc::StringUtils::replaceAll(archivePath, "/", "\\"); Misc::StringUtils::replaceAll(archivePath, "/", "\\");
std::string extractPath = info.extractfile; std::string extractPath = info.extractfile.string(); //TODO(Project579): This will probably break in windows with unicode paths
Misc::StringUtils::replaceAll(extractPath, "\\", "/"); Misc::StringUtils::replaceAll(extractPath, "\\", "/");
Files::IStreamPtr stream; Files::IStreamPtr stream;
@ -204,13 +204,12 @@ int extract(std::unique_ptr<File>& bsa, Arguments& info)
// Get the target path (the path the file will be extracted to) // Get the target path (the path the file will be extracted to)
std::filesystem::path relPath (extractPath); std::filesystem::path relPath (extractPath);
std::filesystem::path outdir (info.outdir);
std::filesystem::path target; std::filesystem::path target;
if (info.fullpath) if (info.fullpath)
target = outdir / relPath; target = info.outdir / relPath;
else else
target = outdir / relPath.filename(); target = info.outdir / relPath.filename();
// Create the directory hierarchy // Create the directory hierarchy
std::filesystem::create_directories(target.parent_path()); std::filesystem::create_directories(target.parent_path());
@ -225,7 +224,7 @@ int extract(std::unique_ptr<File>& bsa, Arguments& info)
std::ofstream out(target, std::ios::binary); std::ofstream out(target, std::ios::binary);
// Write the file to disk // Write the file to disk
std::cout << "Extracting " << info.extractfile << " to " << target << std::endl; std::cout << "Extracting " << info.extractfile << " to " << target << std::endl; //TODO(Project579): This will probably break in windows with unicode paths
out << stream->rdbuf(); out << stream->rdbuf();
out.close(); out.close();
@ -242,7 +241,7 @@ int extractAll(std::unique_ptr<File>& bsa, Arguments& info)
Misc::StringUtils::replaceAll(extractPath, "\\", "/"); Misc::StringUtils::replaceAll(extractPath, "\\", "/");
// Get the target path (the path the file will be extracted to) // Get the target path (the path the file will be extracted to)
std::filesystem::path target (info.outdir); auto target = info.outdir;
target /= extractPath; target /= extractPath;
// Create the directory hierarchy // Create the directory hierarchy
@ -272,7 +271,7 @@ template<typename File>
int add(std::unique_ptr<File>& bsa, Arguments& info) int add(std::unique_ptr<File>& bsa, Arguments& info)
{ {
std::fstream stream(info.addfile, std::ios_base::binary | std::ios_base::out | std::ios_base::in); std::fstream stream(info.addfile, std::ios_base::binary | std::ios_base::out | std::ios_base::in);
bsa->addFile(info.addfile, stream); bsa->addFile(info.addfile.string(), stream); //TODO(Project579): This will probably break in windows with unicode paths
return 0; return 0;
} }

@ -156,9 +156,9 @@ bool parseOptions (int argc, char** argv, Arguments &info)
}*/ }*/
const auto inputFiles = variables["input-file"].as< std::vector<Files::MaybeQuotedPath> >(); const auto inputFiles = variables["input-file"].as< std::vector<Files::MaybeQuotedPath> >();
info.filename = inputFiles[0]; info.filename = inputFiles[0].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
if (inputFiles.size() > 1) if (inputFiles.size() > 1)
info.outname = inputFiles[1]; info.outname = inputFiles[1].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
if (const auto it = variables.find("raw"); it != variables.end()) if (const auto it = variables.find("raw"); it != variables.end())
info.mRawFormat = ESM::parseFormat(it->second.as<std::string>()); info.mRawFormat = ESM::parseFormat(it->second.as<std::string>());

@ -121,7 +121,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
mDocumentManager.setEncoding(ToUTF8::calculateEncoding(mEncodingName)); mDocumentManager.setEncoding(ToUTF8::calculateEncoding(mEncodingName));
mFileDialog.setEncoding (QString::fromUtf8(mEncodingName.c_str())); mFileDialog.setEncoding (QString::fromUtf8(mEncodingName.c_str()));
mDocumentManager.setResourceDir (mResources = variables["resources"].as<Files::MaybeQuotedPath>()); mDocumentManager.setResourceDir (mResources = variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
if (variables["script-blacklist-use"].as<bool>()) if (variables["script-blacklist-use"].as<bool>())
mDocumentManager.setBlacklistedScripts ( mDocumentManager.setBlacklistedScripts (
@ -134,7 +134,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
dataDirs = asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>()); dataDirs = asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>());
} }
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>()); Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
if (!local.empty()) if (!local.empty())
{ {
std::filesystem::create_directories(local); std::filesystem::create_directories(local);

@ -61,7 +61,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
{ {
cfgMgr.readConfiguration(variables, desc, true); cfgMgr.readConfiguration(variables, desc, true);
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>()); Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
getRawStdout() << v.describe() << std::endl; getRawStdout() << v.describe() << std::endl;
return false; return false;
} }
@ -72,7 +72,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
setupLogging(cfgMgr.getLogPath(), "OpenMW"); setupLogging(cfgMgr.getLogPath(), "OpenMW");
MWGui::DebugWindow::startLogRecording(); MWGui::DebugWindow::startLogRecording();
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>()); Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
Log(Debug::Info) << v.describe(); Log(Debug::Info) << v.describe();
engine.setGrabMouse(!variables["no-grab"].as<bool>()); engine.setGrabMouse(!variables["no-grab"].as<bool>());
@ -87,13 +87,13 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
Files::PathContainer dataDirs(asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>())); Files::PathContainer dataDirs(asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>()));
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>()); Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
if (!local.empty()) if (!local.empty())
dataDirs.push_back(local); dataDirs.push_back(local);
cfgMgr.filterOutNonExistingPaths(dataDirs); cfgMgr.filterOutNonExistingPaths(dataDirs);
engine.setResourceDir(variables["resources"].as<Files::MaybeQuotedPath>()); engine.setResourceDir(variables["resources"].as<Files::MaybeQuotedPath>().u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
engine.setDataDirs(dataDirs); engine.setDataDirs(dataDirs);
// fallback archives // fallback archives
@ -150,7 +150,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setWarningsMode (variables["script-warn"].as<int>()); engine.setWarningsMode (variables["script-warn"].as<int>());
engine.setScriptBlacklist (variables["script-blacklist"].as<StringsVector>()); engine.setScriptBlacklist (variables["script-blacklist"].as<StringsVector>());
engine.setScriptBlacklistUse (variables["script-blacklist-use"].as<bool>()); engine.setScriptBlacklistUse (variables["script-blacklist-use"].as<bool>());
engine.setSaveGameFile (variables["load-savegame"].as<Files::MaybeQuotedPath>()); engine.setSaveGameFile (variables["load-savegame"].as<Files::MaybeQuotedPath>().u8string());
// other settings // other settings
Fallback::Map::init(variables["fallback"].as<FallbackMap>().mMap); Fallback::Map::init(variables["fallback"].as<FallbackMap>().mMap);

@ -74,7 +74,7 @@ struct ContentFileTest : public ::testing::Test
dataDirs = asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>()); dataDirs = asPathContainer(variables["data"].as<Files::MaybeQuotedPathContainer>());
} }
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>()); Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>().u8string());
if (!local.empty()) if (!local.empty())
dataLocal.push_back(local); dataLocal.push_back(local);

@ -137,7 +137,7 @@ void ConfigurationManager::readConfiguration(bpo::variables_map& variables,
mergeComposingVariables(variables, composingVariables, description); mergeComposingVariables(variables, composingVariables, description);
} }
mUserDataPath = variables["user-data"].as<Files::MaybeQuotedPath>(); mUserDataPath = variables["user-data"].as<Files::MaybeQuotedPath>().u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
if (mUserDataPath.empty()) if (mUserDataPath.empty())
{ {
if (!quiet) if (!quiet)
@ -451,7 +451,13 @@ std::istream& operator>> (std::istream& istream, MaybeQuotedPath& MaybeQuotedPat
PathContainer asPathContainer(const MaybeQuotedPathContainer& MaybeQuotedPathContainer) PathContainer asPathContainer(const MaybeQuotedPathContainer& MaybeQuotedPathContainer)
{ {
return PathContainer(MaybeQuotedPathContainer.begin(), MaybeQuotedPathContainer.end()); PathContainer res;
res.reserve(MaybeQuotedPathContainer.size());
for (const auto & maybeQuotedPath : MaybeQuotedPathContainer)
{
res.emplace_back(maybeQuotedPath.u8string()); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.
}
return res;
} }
} /* namespace Files */ } /* namespace Files */

@ -6,6 +6,7 @@
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <filesystem> #include <filesystem>
#include <fstream>
#include <components/misc/strings/lower.hpp> #include <components/misc/strings/lower.hpp>
@ -90,7 +91,7 @@ std::filesystem::path MacOsPath::getInstallPath() const
if (std::filesystem::is_regular_file(wineDefaultRegistry)) if (std::filesystem::is_regular_file(wineDefaultRegistry))
{ {
std::filesystem::ifstream file(wineDefaultRegistry); std::ifstream file(wineDefaultRegistry);
bool isRegEntry = false; bool isRegEntry = false;
std::string line; std::string line;
std::string mwpath; std::string mwpath;

Loading…
Cancel
Save