mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 12:54:00 +00:00
Attempt to unescape characters when constructing file paths, introducing compilation errors.
This commit is contained in:
parent
4ac5174d89
commit
95d2c7ea5c
@ -76,7 +76,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
||||
desc.add_options()
|
||||
("help", "print help message")
|
||||
("version", "print version information and quit")
|
||||
("data", bpo::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")
|
||||
("data", bpo::value<Files::EscapePathContainer>()->default_value(Files::EscapePathContainer(), "data")
|
||||
->multitoken()->composing(), "set data directories (later directories have higher priority)")
|
||||
|
||||
("data-local", bpo::value<Files::EscapeHashString>()->default_value(""),
|
||||
@ -193,7 +193,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
||||
// directory settings
|
||||
engine.enableFSStrict(variables["fs-strict"].as<bool>());
|
||||
|
||||
Files::PathContainer dataDirs(variables["data"].as<Files::PathContainer>());
|
||||
Files::PathContainer dataDirs(variables["data"].as<Files::EscapePathContainer>().mContainer);
|
||||
|
||||
std::string local(variables["data-local"].as<Files::EscapeHashString>().toStdString());
|
||||
if (!local.empty())
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/multidircollection.hpp>
|
||||
|
||||
// Parses and validates a fallback map from boost program_options.
|
||||
// Note: for boost to pick up the validate function, you need to pull in the namespace e.g.
|
||||
@ -66,6 +67,23 @@ namespace Files {
|
||||
for (std::vector<std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
|
||||
eSV->mVector.push_back(EscapeHashString(*it));
|
||||
}
|
||||
|
||||
struct EscapePathContainer {
|
||||
PathContainer mContainer;
|
||||
};
|
||||
|
||||
std::istream & operator>> (std::istream & istream, EscapePathContainer & escapePathContainer)
|
||||
{
|
||||
std::cout << "The new dodgy operator>> is being used" << std::endl;
|
||||
|
||||
boost::iostreams::filtering_istream filteredStream;
|
||||
filteredStream.push(unescape_hash_filter());
|
||||
filteredStream.push(istream);
|
||||
|
||||
filteredStream >> escapePathContainer.mContainer;
|
||||
|
||||
return istream;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -237,6 +237,30 @@ int escape_hash_filter::get(Source & src)
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <typename Source>
|
||||
int unescape_hash_filter::get(Source & src)
|
||||
{
|
||||
int character = boost::iostreams::get(src);
|
||||
if (character == escape_hash_filter::sEscape)
|
||||
{
|
||||
int nextChar = boost::iostreams::get(src);
|
||||
switch (nextChar)
|
||||
{
|
||||
case escape_hash_filter::sEscapeIdentifier:
|
||||
return escape_hash_filter::sEscape;
|
||||
break;
|
||||
case escape_hash_filter::sHashIdentifier:
|
||||
return '#';
|
||||
break;
|
||||
default:
|
||||
return '?';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
return character;
|
||||
}
|
||||
|
||||
std::string EscapeHashString::processString(const std::string & str)
|
||||
{
|
||||
std::string temp = boost::replace_all_copy<std::string>(str, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sHashIdentifier, "#");
|
||||
|
@ -88,6 +88,11 @@ struct escape_hash_filter : public boost::iostreams::input_filter
|
||||
bool mFinishLine;
|
||||
};
|
||||
|
||||
struct unescape_hash_filter : public boost::iostreams::input_filter
|
||||
{
|
||||
template <typename Source> int get(Source & src);
|
||||
};
|
||||
|
||||
/**
|
||||
* \class EscapeHashString
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user