Update some settings that accept paths by "std::string" to accept them as "std::filesystem::path" instead.

crashfix_debugdraw
Project579 2 years ago
parent 2df8bfed25
commit 4e428dee12

@ -57,7 +57,7 @@ bool parseOptions (int argc, char** argv, Arguments &info)
hidden.add_options()
( "mode,m", bpo::value<std::string>(), "bsatool mode")
( "input-file,i", bpo::value< std::vector<std::string> >(), "input file")
( "input-file,i", bpo::value< Files::MaybeQuotedPathContainer >(), "input file")
;
bpo::positional_options_description p;
@ -114,7 +114,7 @@ bool parseOptions (int argc, char** argv, Arguments &info)
<< desc << std::endl;
return false;
}
auto inputFiles = variables["input-file"].as< std::vector<Files::MaybeQuotedPath> >();
auto inputFiles = variables["input-file"].as< Files::MaybeQuotedPathContainer >();
info.filename = inputFiles[0].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.

@ -85,7 +85,7 @@ bool parseOptions (int argc, char** argv, Arguments &info)
hidden.add_options()
( "mode,m", bpo::value<std::string>(), "esmtool mode")
( "input-file,i", bpo::value< std::vector<std::string> >(), "input file")
( "input-file,i", bpo::value< Files::MaybeQuotedPathContainer >(), "input file")
;
bpo::positional_options_description p;
@ -156,7 +156,7 @@ bool parseOptions (int argc, char** argv, Arguments &info)
return false;
}*/
const auto inputFiles = variables["input-file"].as< std::vector<Files::MaybeQuotedPath> >();
const auto inputFiles = variables["input-file"].as< Files::MaybeQuotedPathContainer >();
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].u8string(); // This call to u8string is redundant, but required to build on MSVC 14.26 due to implementation bugs.

@ -18,8 +18,8 @@ int main(int argc, char** argv)
bpo::positional_options_description p_desc;
desc.add_options()
("help,h", "produce help message")
("mwsave,m", bpo::value<std::string>(), "morrowind .ess save file")
("output,o", bpo::value<std::string>(), "output file (.omwsave)")
("mwsave,m", bpo::value<Files::MaybeQuotedPath>(), "morrowind .ess save file")
("output,o", bpo::value<Files::MaybeQuotedPath>(), "output file (.omwsave)")
("compare,c", "compare two .ess files")
("encoding", boost::program_options::value<std::string>()->default_value("win1252"), "encoding of the save file")
;
@ -45,8 +45,8 @@ int main(int argc, char** argv)
Files::ConfigurationManager cfgManager(true);
cfgManager.readConfiguration(variables, desc);
std::string essFile = variables["mwsave"].as<std::string>();
std::string outputFile = variables["output"].as<std::string>();
const auto essFile = variables["mwsave"].as<Files::MaybeQuotedPath>();
const auto outputFile = variables["output"].as<Files::MaybeQuotedPath>();
std::string encoding = variables["encoding"].as<std::string>();
ESSImport::Importer importer(essFile, outputFile, encoding);
@ -55,9 +55,10 @@ int main(int argc, char** argv)
importer.compare();
else
{
const std::string& ext = ".omwsave";
if (std::filesystem::exists(std::filesystem::path(outputFile))
&& (outputFile.size() < ext.size() || outputFile.substr(outputFile.size()-ext.size()) != ext))
static constexpr std::u8string_view ext{u8".omwsave"};
const auto length = outputFile.native().size();
if (std::filesystem::exists(outputFile)
&& (length < ext.size() || outputFile.u8string().substr(length-ext.size()) != ext))
{
throw std::runtime_error("Output file already exists and does not end in .omwsave. Did you mean to use --compare?");
}

@ -6,6 +6,8 @@
#include <boost/program_options.hpp>
#include <components/files/configurationmanager.hpp>
namespace bpo = boost::program_options;
namespace sfs = std::filesystem;
@ -61,9 +63,9 @@ int wmain(int argc, wchar_t *wargv[]) {
desc.add_options()
("help,h", "produce help message")
("verbose,v", "verbose output")
("ini,i", bpo::value<std::string>(), "morrowind.ini file")
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
("ini,i", bpo::value<Files::MaybeQuotedPath>(), "morrowind.ini file")
("cfg,c", bpo::value<Files::MaybeQuotedPath>(), "openmw.cfg file")
("output,o", bpo::value<Files::MaybeQuotedPath>()->default_value({}), "openmw.cfg file")
("game-files,g", "import esm and esp files")
("fonts,f", "import bitmap fonts")
("no-archives,A", "disable bsa archives import")
@ -91,13 +93,13 @@ int wmain(int argc, wchar_t *wargv[]) {
bpo::notify(vm);
std::filesystem::path iniFile(vm["ini"].as<std::string>());
std::filesystem::path cfgFile(vm["cfg"].as<std::string>());
std::filesystem::path iniFile(vm["ini"].as<Files::MaybeQuotedPath>());
std::filesystem::path cfgFile(vm["cfg"].as<Files::MaybeQuotedPath>());
// if no output is given, write back to cfg file
std::string outputFile(vm["output"].as<std::string>());
std::string outputFile(vm["output"].as<Files::MaybeQuotedPath>());
if(vm["output"].defaulted()) {
outputFile = vm["cfg"].as<std::string>();
outputFile = vm["cfg"].as<Files::MaybeQuotedPath>();
}
if(!std::filesystem::exists(iniFile)) {

@ -77,7 +77,7 @@ bool parseOptions (int argc, char** argv, std::vector<Files::MaybeQuotedPath> &f
"Allowed options");
desc.add_options()
("help,h", "print help message.")
("input-file", bpo::value< std::vector<Files::MaybeQuotedPath> >(), "input file")
("input-file", bpo::value< Files::MaybeQuotedPathContainer >(), "input file")
;
//Default option if none provided
@ -98,7 +98,7 @@ bool parseOptions (int argc, char** argv, std::vector<Files::MaybeQuotedPath> &f
}
if (variables.count("input-file"))
{
files = variables["input-file"].as< std::vector<Files::MaybeQuotedPath> >();
files = variables["input-file"].as< Files::MaybeQuotedPathContainer >();
return true;
}
}

Loading…
Cancel
Save