Lots of UTF8 path correctness fixes
This commit is contained in:
parent
5b41f374c6
commit
27410761f3
12 changed files with 34 additions and 40 deletions
|
@ -544,7 +544,7 @@ std::vector<std::string> FGAIBase::resolveModelPath(ModelSearchOrder searchOrder
|
||||||
for (SGPath p : globals->get_data_paths("AI")) {
|
for (SGPath p : globals->get_data_paths("AI")) {
|
||||||
p.append(model_path);
|
p.append(model_path);
|
||||||
if (p.exists()) {
|
if (p.exists()) {
|
||||||
SG_LOG(SG_AI, SG_DEBUG, "Found AI model: " << p.local8BitStr());
|
SG_LOG(SG_AI, SG_DEBUG, "Found AI model: " << p);
|
||||||
path_list.push_back(p.local8BitStr());
|
path_list.push_back(p.local8BitStr());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace canvas
|
||||||
"canvas::Text: using font file " << path
|
"canvas::Text: using font file " << path
|
||||||
);
|
);
|
||||||
|
|
||||||
simgear::canvas::FontPtr font = osgText::readFontFile(path.local8BitStr());
|
simgear::canvas::FontPtr font = osgText::readFontFile(path.utf8Str());
|
||||||
if( !font )
|
if( !font )
|
||||||
SG_LOG
|
SG_LOG
|
||||||
(
|
(
|
||||||
|
@ -86,9 +86,9 @@ namespace canvas
|
||||||
SGPath valid_path = fgValidatePath(p, false);
|
SGPath valid_path = fgValidatePath(p, false);
|
||||||
if( !valid_path.isNull() )
|
if( !valid_path.isNull() )
|
||||||
#if OSG_VERSION_LESS_THAN(3,4,0)
|
#if OSG_VERSION_LESS_THAN(3,4,0)
|
||||||
return osgDB::readRefImageFile(valid_path.local8BitStr());
|
return osgDB::readRefImageFile(valid_path.utf8Str());
|
||||||
#else
|
#else
|
||||||
return osgDB::readRefImageFile(valid_path.local8BitStr());
|
return osgDB::readRefImageFile(valid_path.utf8Str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: reading '" << path << "' denied");
|
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: reading '" << path << "' denied");
|
||||||
|
@ -98,9 +98,9 @@ namespace canvas
|
||||||
SGPath tpath = globals->resolve_resource_path(path);
|
SGPath tpath = globals->resolve_resource_path(path);
|
||||||
if( !tpath.isNull() )
|
if( !tpath.isNull() )
|
||||||
#if OSG_VERSION_LESS_THAN(3,4,0)
|
#if OSG_VERSION_LESS_THAN(3,4,0)
|
||||||
return osgDB::readImageFile(tpath.local8BitStr());
|
return osgDB::readImageFile(tpath.utf8Str());
|
||||||
#else
|
#else
|
||||||
return osgDB::readRefImageFile(tpath.local8BitStr());
|
return osgDB::readRefImageFile(tpath.utf8Str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: No such image: '" << path << "'");
|
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: No such image: '" << path << "'");
|
||||||
|
|
|
@ -777,7 +777,7 @@ NavDisplay::updateFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
||||||
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.local8BitStr(), fontOptions.get());
|
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.utf8Str(), fontOptions.get());
|
||||||
|
|
||||||
if (font != 0) {
|
if (font != 0) {
|
||||||
_font = font;
|
_font = font;
|
||||||
|
|
|
@ -1084,7 +1084,7 @@ wxRadarBg::updateFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
||||||
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.local8BitStr(), fontOptions.get());
|
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.utf8Str(), fontOptions.get());
|
||||||
|
|
||||||
if (font != 0) {
|
if (font != 0) {
|
||||||
_font = font;
|
_font = font;
|
||||||
|
|
|
@ -54,7 +54,7 @@ void Ephemeris::init()
|
||||||
{
|
{
|
||||||
SGPath ephem_data_path(globals->get_fg_root());
|
SGPath ephem_data_path(globals->get_fg_root());
|
||||||
ephem_data_path.append("Astro");
|
ephem_data_path.append("Astro");
|
||||||
_impl.reset(new SGEphemeris(ephem_data_path.local8BitStr()));
|
_impl.reset(new SGEphemeris(ephem_data_path));
|
||||||
|
|
||||||
tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
|
tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
|
||||||
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
|
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
|
||||||
|
|
|
@ -37,7 +37,7 @@ AddonsModel::AddonsModel(QObject* pr) :
|
||||||
int roleValue = IdRole;
|
int roleValue = IdRole;
|
||||||
|
|
||||||
for (auto it = m_roles.begin(); it != m_roles.end(); ++it) {
|
for (auto it = m_roles.begin(); it != m_roles.end(); ++it) {
|
||||||
QByteArray name = (*it).toLocal8Bit();
|
QByteArray name = it->toUtf8();
|
||||||
m_roleToName[roleValue] = name;
|
m_roleToName[roleValue] = name;
|
||||||
m_nameToRole[*it] = roleValue++;
|
m_nameToRole[*it] = roleValue++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <plib/pu.h>
|
#include <plib/pu.h>
|
||||||
|
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
|
#include <simgear/misc/sg_dir.hxx>
|
||||||
|
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
|
|
||||||
|
@ -211,26 +212,19 @@ FGFontCache::getfntpath(const std::string& name)
|
||||||
|
|
||||||
bool FGFontCache::initializeFonts()
|
bool FGFontCache::initializeFonts()
|
||||||
{
|
{
|
||||||
static std::string fontext("txf");
|
static std::string fontext(",txf");
|
||||||
init();
|
init();
|
||||||
std::string fontPath = _path.local8BitStr();
|
|
||||||
ulDir* fontdir = ulOpenDir(fontPath.c_str());
|
auto dir = simgear::Dir(_path);
|
||||||
if (!fontdir)
|
for (auto p : dir.children(simgear::Dir::TYPE_FILE, fontext)) {
|
||||||
return false;
|
fntTexFont* f = new fntTexFont;
|
||||||
const ulDirEnt *dirEntry;
|
// FIXME : this will fail when fonts are on UTF8 paths
|
||||||
while ((dirEntry = ulReadDir(fontdir)) != 0) {
|
if (f->load(p.local8BitStr()))
|
||||||
SGPath path(_path);
|
_texFonts[p.file()] = f;
|
||||||
path.append(dirEntry->d_name);
|
else
|
||||||
if (path.extension() == fontext) {
|
delete f;
|
||||||
fntTexFont* f = new fntTexFont;
|
|
||||||
std::string ps = path.local8BitStr();
|
|
||||||
if (f->load(ps.c_str()))
|
|
||||||
_texFonts[std::string(dirEntry->d_name)] = f;
|
|
||||||
else
|
|
||||||
delete f;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ulCloseDir(fontdir);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,7 +483,7 @@ bool fgInitHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[16];
|
char buf[16];
|
||||||
std::string ps = pidPath.local8BitStr();
|
std::string ps = pidPath.utf8Str();
|
||||||
|
|
||||||
// do open+unlink trick to the file is deleted on exit, even if we
|
// do open+unlink trick to the file is deleted on exit, even if we
|
||||||
// crash or exit(-1)
|
// crash or exit(-1)
|
||||||
|
@ -873,8 +873,7 @@ void fgCreateSubsystems(bool duringReset) {
|
||||||
|
|
||||||
SGPath mpath( globals->get_fg_root() );
|
SGPath mpath( globals->get_fg_root() );
|
||||||
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
||||||
if ( ! globals->get_matlib()->load(globals->get_fg_root().local8BitStr(), mpath.local8BitStr(),
|
if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath, globals->get_props()) ) {
|
||||||
globals->get_props()) ) {
|
|
||||||
throw sg_io_exception("Error loading materials file", mpath);
|
throw sg_io_exception("Error loading materials file", mpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -364,9 +364,7 @@ void FGGlobals::append_fg_scenery (const SGPath &path)
|
||||||
|
|
||||||
// tell the ResouceManager about the scenery path
|
// tell the ResouceManager about the scenery path
|
||||||
// needed to load Models from this scenery path
|
// needed to load Models from this scenery path
|
||||||
simgear::ResourceManager::instance()->addBasePath(abspath.local8BitStr(),
|
simgear::ResourceManager::instance()->addBasePath(abspath, simgear::ResourceManager::PRIORITY_DEFAULT);
|
||||||
simgear::ResourceManager::PRIORITY_DEFAULT);
|
|
||||||
simgear::Dir dir(abspath);
|
|
||||||
|
|
||||||
fg_scenery.push_back(abspath);
|
fg_scenery.push_back(abspath);
|
||||||
extra_read_allowed_paths.push_back(abspath);
|
extra_read_allowed_paths.push_back(abspath);
|
||||||
|
|
|
@ -91,8 +91,13 @@ namespace flightgear
|
||||||
void SHPParser::parsePolyLines(const SGPath& aPath, PolyLine::Type aTy,
|
void SHPParser::parsePolyLines(const SGPath& aPath, PolyLine::Type aTy,
|
||||||
PolyLineList& aResult, bool aClosed)
|
PolyLineList& aResult, bool aClosed)
|
||||||
{
|
{
|
||||||
std::string s = aPath.local8BitStr();
|
#if defined(SG_WINDOWS)
|
||||||
|
const auto ws = aPath.wstr();
|
||||||
|
gzFile file = gzopen_w(ws.c_str(), "rb");
|
||||||
|
#else
|
||||||
|
const auto s = aPath.utf8Str();
|
||||||
gzFile file = gzopen(s.c_str(), "rb");
|
gzFile file = gzopen(s.c_str(), "rb");
|
||||||
|
#endif
|
||||||
if (!file) {
|
if (!file) {
|
||||||
throw sg_io_exception("couldn't open file:", aPath);
|
throw sg_io_exception("couldn't open file:", aPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,10 +172,10 @@ void FGTileMgr::reinit()
|
||||||
for (it = sc.begin(); it != sc.end(); ++it) {
|
for (it = sc.begin(); it != sc.end(); ++it) {
|
||||||
fp.push_back(it->local8BitStr());
|
fp.push_back(it->local8BitStr());
|
||||||
}
|
}
|
||||||
_options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root().local8BitStr());
|
_options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root().utf8Str());
|
||||||
|
|
||||||
if (_terra_sync) {
|
if (_terra_sync) {
|
||||||
_options->setPluginStringData("SimGear::TERRASYNC_ROOT", globals->get_terrasync_dir().local8BitStr());
|
_options->setPluginStringData("SimGear::TERRASYNC_ROOT", globals->get_terrasync_dir().utf8Str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_disableNasalHooks->getBoolValue())
|
if (!_disableNasalHooks->getBoolValue())
|
||||||
|
|
|
@ -386,9 +386,7 @@ void TimeManager::throttleUpdateRate()
|
||||||
// periodic time updater wrapper
|
// periodic time updater wrapper
|
||||||
void TimeManager::updateLocalTime()
|
void TimeManager::updateLocalTime()
|
||||||
{
|
{
|
||||||
SGPath zone(globals->get_fg_root());
|
_impl->updateLocal(globals->get_aircraft_position(), globals->get_fg_root() / "Timezone");
|
||||||
zone.append("Timezone");
|
|
||||||
_impl->updateLocal(globals->get_aircraft_position(), zone.local8BitStr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeManager::initTimeOffset()
|
void TimeManager::initTimeOffset()
|
||||||
|
|
Loading…
Add table
Reference in a new issue