mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 14:49:40 +00:00
Attempt to unescape characters when constructing file paths, introducing compilation errors.
This commit is contained in:
parent
4ac5174d89
commit
95d2c7ea5c
4 changed files with 49 additions and 2 deletions
|
@ -76,7 +76,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("help", "print help message")
|
("help", "print help message")
|
||||||
("version", "print version information and quit")
|
("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)")
|
->multitoken()->composing(), "set data directories (later directories have higher priority)")
|
||||||
|
|
||||||
("data-local", bpo::value<Files::EscapeHashString>()->default_value(""),
|
("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
|
// directory settings
|
||||||
engine.enableFSStrict(variables["fs-strict"].as<bool>());
|
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());
|
std::string local(variables["data-local"].as<Files::EscapeHashString>().toStdString());
|
||||||
if (!local.empty())
|
if (!local.empty())
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
|
|
||||||
// Parses and validates a fallback map from boost program_options.
|
// 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.
|
// 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)
|
for (std::vector<std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
|
||||||
eSV->mVector.push_back(EscapeHashString(*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
|
#endif
|
||||||
|
|
|
@ -237,6 +237,30 @@ int escape_hash_filter::get(Source & src)
|
||||||
return retval;
|
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 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, "#");
|
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;
|
bool mFinishLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct unescape_hash_filter : public boost::iostreams::input_filter
|
||||||
|
{
|
||||||
|
template <typename Source> int get(Source & src);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class EscapeHashString
|
* \class EscapeHashString
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue