diff --git a/apps/bsatool/bsatool.cpp b/apps/bsatool/bsatool.cpp index 16c25594c6..6313b92e95 100644 --- a/apps/bsatool/bsatool.cpp +++ b/apps/bsatool/bsatool.cpp @@ -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 >(); - 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& bsa, Arguments& info) template int extract(std::unique_ptr& 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& 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& 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& 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 int add(std::unique_ptr& 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; } diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index fa46b4d910..f95777d0ef 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -156,9 +156,9 @@ bool parseOptions (int argc, char** argv, Arguments &info) }*/ const auto inputFiles = variables["input-file"].as< std::vector >(); - 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()); diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 9a988991f0..8dee97bd46 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -121,7 +121,7 @@ std::pair > CS::Editor::readConfi mDocumentManager.setEncoding(ToUTF8::calculateEncoding(mEncodingName)); mFileDialog.setEncoding (QString::fromUtf8(mEncodingName.c_str())); - mDocumentManager.setResourceDir (mResources = variables["resources"].as()); + mDocumentManager.setResourceDir (mResources = variables["resources"].as().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()) mDocumentManager.setBlacklistedScripts ( @@ -134,7 +134,7 @@ std::pair > CS::Editor::readConfi dataDirs = asPathContainer(variables["data"].as()); } - Files::PathContainer::value_type local(variables["data-local"].as()); + Files::PathContainer::value_type local(variables["data-local"].as().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); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index c327683bee..9700142ab8 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -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()); + Version::Version v = Version::getOpenmwVersion(variables["resources"].as().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()); + Version::Version v = Version::getOpenmwVersion(variables["resources"].as().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()); @@ -87,13 +87,13 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat Files::PathContainer dataDirs(asPathContainer(variables["data"].as())); - Files::PathContainer::value_type local(variables["data-local"].as()); + Files::PathContainer::value_type local(variables["data-local"].as().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()); + engine.setResourceDir(variables["resources"].as().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()); engine.setScriptBlacklist (variables["script-blacklist"].as()); engine.setScriptBlacklistUse (variables["script-blacklist-use"].as()); - engine.setSaveGameFile (variables["load-savegame"].as()); + engine.setSaveGameFile (variables["load-savegame"].as().u8string()); // other settings Fallback::Map::init(variables["fallback"].as().mMap); diff --git a/apps/openmw_test_suite/mwworld/test_store.cpp b/apps/openmw_test_suite/mwworld/test_store.cpp index b5fbf5a291..ba0abd293d 100644 --- a/apps/openmw_test_suite/mwworld/test_store.cpp +++ b/apps/openmw_test_suite/mwworld/test_store.cpp @@ -74,7 +74,7 @@ struct ContentFileTest : public ::testing::Test dataDirs = asPathContainer(variables["data"].as()); } - Files::PathContainer::value_type local(variables["data-local"].as()); + Files::PathContainer::value_type local(variables["data-local"].as().u8string()); if (!local.empty()) dataLocal.push_back(local); diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 0fc228abee..6ceab167e5 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -137,7 +137,7 @@ void ConfigurationManager::readConfiguration(bpo::variables_map& variables, mergeComposingVariables(variables, composingVariables, description); } - mUserDataPath = variables["user-data"].as(); + mUserDataPath = variables["user-data"].as().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 */ diff --git a/components/files/macospath.cpp b/components/files/macospath.cpp index c0505dbea0..e6dc8e55b7 100644 --- a/components/files/macospath.cpp +++ b/components/files/macospath.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -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;