mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 07:45:36 +00:00
Fixed Windows build when using MSVC 14.26 and MacOS build.
This commit is contained in:
parent
6bf4c7a04f
commit
864112b5db
7 changed files with 36 additions and 30 deletions
|
@ -19,9 +19,9 @@ struct Arguments
|
|||
{
|
||||
std::string mode;
|
||||
std::filesystem::path filename;
|
||||
std::string extractfile;
|
||||
std::string addfile;
|
||||
std::string outdir;
|
||||
std::filesystem::path extractfile;
|
||||
std::filesystem::path addfile;
|
||||
std::filesystem::path outdir;
|
||||
|
||||
bool longformat;
|
||||
bool fullpath;
|
||||
|
@ -115,10 +115,10 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
}
|
||||
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
|
||||
info.outdir = ".";
|
||||
info.outdir = std::filesystem::current_path();
|
||||
|
||||
if (info.mode == "extract")
|
||||
{
|
||||
|
@ -129,9 +129,9 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
return false;
|
||||
}
|
||||
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)
|
||||
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")
|
||||
{
|
||||
|
@ -142,10 +142,10 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
return false;
|
||||
}
|
||||
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)
|
||||
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.fullpath = variables.count("full-path") != 0;
|
||||
|
@ -179,10 +179,10 @@ int list(std::unique_ptr<File>& bsa, Arguments& info)
|
|||
template<typename File>
|
||||
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, "/", "\\");
|
||||
|
||||
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, "\\", "/");
|
||||
|
||||
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)
|
||||
std::filesystem::path relPath (extractPath);
|
||||
std::filesystem::path outdir (info.outdir);
|
||||
|
||||
std::filesystem::path target;
|
||||
if (info.fullpath)
|
||||
target = outdir / relPath;
|
||||
target = info.outdir / relPath;
|
||||
else
|
||||
target = outdir / relPath.filename();
|
||||
target = info.outdir / relPath.filename();
|
||||
|
||||
// Create the directory hierarchy
|
||||
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);
|
||||
|
||||
// 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.close();
|
||||
|
@ -242,7 +241,7 @@ int extractAll(std::unique_ptr<File>& bsa, Arguments& info)
|
|||
Misc::StringUtils::replaceAll(extractPath, "\\", "/");
|
||||
|
||||
// Get the target path (the path the file will be extracted to)
|
||||
std::filesystem::path target (info.outdir);
|
||||
auto target = info.outdir;
|
||||
target /= extractPath;
|
||||
|
||||
// Create the directory hierarchy
|
||||
|
@ -272,7 +271,7 @@ template<typename File>
|
|||
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);
|
||||
bsa->addFile(info.addfile, stream);
|
||||
bsa->addFile(info.addfile.string(), stream); //TODO(Project579): This will probably break in windows with unicode paths
|
||||
|
||||
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> >();
|
||||
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)
|
||||
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())
|
||||
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));
|
||||
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>())
|
||||
mDocumentManager.setBlacklistedScripts (
|
||||
|
@ -134,7 +134,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||
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())
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
setupLogging(cfgMgr.getLogPath(), "OpenMW");
|
||||
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();
|
||||
|
||||
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::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())
|
||||
dataDirs.push_back(local);
|
||||
|
||||
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);
|
||||
|
||||
// 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.setScriptBlacklist (variables["script-blacklist"].as<StringsVector>());
|
||||
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
|
||||
Fallback::Map::init(variables["fallback"].as<FallbackMap>().mMap);
|
||||
|
|
|
@ -74,7 +74,7 @@ struct ContentFileTest : public ::testing::Test
|
|||
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())
|
||||
dataLocal.push_back(local);
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ void ConfigurationManager::readConfiguration(bpo::variables_map& variables,
|
|||
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 (!quiet)
|
||||
|
@ -451,7 +451,13 @@ std::istream& operator>> (std::istream& istream, MaybeQuotedPath& MaybeQuotedPat
|
|||
|
||||
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 */
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
|
||||
|
@ -90,7 +91,7 @@ std::filesystem::path MacOsPath::getInstallPath() const
|
|||
|
||||
if (std::filesystem::is_regular_file(wineDefaultRegistry))
|
||||
{
|
||||
std::filesystem::ifstream file(wineDefaultRegistry);
|
||||
std::ifstream file(wineDefaultRegistry);
|
||||
bool isRegEntry = false;
|
||||
std::string line;
|
||||
std::string mwpath;
|
||||
|
|
Loading…
Reference in a new issue