1
0
Fork 0

Work with new SGPath API.

This commit is contained in:
James Turner 2016-06-21 12:28:35 +01:00
parent 6f95e61da8
commit 03ecac9dbc
27 changed files with 63 additions and 64 deletions

View file

@ -234,9 +234,9 @@ bool FGAIFlightPlan::parseProperties(const std::string& filename)
SGPropertyNode root; SGPropertyNode root;
try { try {
readProperties(path.str(), &root); readProperties(path, &root);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {
SG_LOG(SG_AI, SG_ALERT, "Error reading AI flight plan: " << path.str() SG_LOG(SG_AI, SG_ALERT, "Error reading AI flight plan: " << path
<< "message:" << e.getFormattedMessage()); << "message:" << e.getFormattedMessage());
return false; return false;
} }

View file

@ -507,11 +507,11 @@ FGAIManager::loadScenarioFile(const std::string& filename)
path.append("AI/" + filename + ".xml"); path.append("AI/" + filename + ".xml");
try { try {
SGPropertyNode_ptr root = new SGPropertyNode; SGPropertyNode_ptr root = new SGPropertyNode;
readProperties(path.str(), root); readProperties(path, root);
return root; return root;
} catch (const sg_exception &t) { } catch (const sg_exception &t) {
SG_LOG(SG_AI, SG_ALERT, "Failed to load scenario '" SG_LOG(SG_AI, SG_ALERT, "Failed to load scenario '"
<< path.str() << "': " << t.getFormattedMessage()); << path << "': " << t.getFormattedMessage());
} }
return 0; return 0;
} }

View file

@ -111,10 +111,10 @@ void PerformanceDB::load(const SGPath& filename)
{ {
SGPropertyNode root; SGPropertyNode root;
try { try {
readProperties(filename.str(), &root); readProperties(filename, &root);
} catch (const sg_exception &) { } catch (const sg_exception &) {
SG_LOG(SG_AI, SG_ALERT, SG_LOG(SG_AI, SG_ALERT,
"Error reading AI aircraft performance database: " << filename.str()); "Error reading AI aircraft performance database: " << filename);
return; return;
} }

View file

@ -484,12 +484,12 @@ void FGSubmodelMgr::setData(int id, const string& path, bool serviceable, const
SGPath config = globals->resolve_aircraft_path(path); SGPath config = globals->resolve_aircraft_path(path);
try { try {
SG_LOG(SG_AI, SG_DEBUG, SG_LOG(SG_AI, SG_DEBUG,
"Submodels: Trying to read AI submodels file: " << config.str()); "Submodels: Trying to read AI submodels file: " << config);
readProperties(config.str(), &root); readProperties(config, &root);
} }
catch (const sg_exception &) { catch (const sg_exception &) {
SG_LOG(SG_AI, SG_ALERT, SG_LOG(SG_AI, SG_ALERT,
"Submodels: Unable to read AI submodels file: " << config.str()); "Submodels: Unable to read AI submodels file: " << config);
return; return;
} }

View file

@ -193,7 +193,7 @@ string ATISEncoder::encodeATIS( ATISInformationProvider * atisInformation )
try try
{ {
SGPath path = globals->resolve_maybe_aircraft_path("ATC/atis.xml"); SGPath path = globals->resolve_maybe_aircraft_path("ATC/atis.xml");
readProperties( path.str(), atisSchemaNode ); readProperties( path, atisSchemaNode );
} }
catch (const sg_exception& e) catch (const sg_exception& e)
{ {

View file

@ -180,7 +180,7 @@ FGFlightRecorder::getDefault(void)
{ {
try try
{ {
readProperties(path.str(), m_RecorderNode->getChild("config", 0 ,true), 0); readProperties(path, m_RecorderNode->getChild("config", 0 ,true), 0);
ConfigNode = m_RecorderNode->getChild("config", 0 ,false); ConfigNode = m_RecorderNode->getChild("config", 0 ,false);
} catch (sg_io_exception &e) } catch (sg_io_exception &e)
{ {

View file

@ -564,7 +564,7 @@ void FGAirport::loadProcedures() const
return; return;
} }
SG_LOG(SG_GENERAL, SG_INFO, ident() << ": loading procedures from " << path.str()); SG_LOG(SG_GENERAL, SG_INFO, ident() << ": loading procedures from " << path);
RouteBase::loadAirportProcedures(path, const_cast<FGAirport*>(this)); RouteBase::loadAirportProcedures(path, const_cast<FGAirport*>(this));
} }
@ -583,7 +583,7 @@ void FGAirport::loadSceneryDefinitions() const
try { try {
SGPropertyNode_ptr rootNode = new SGPropertyNode; SGPropertyNode_ptr rootNode = new SGPropertyNode;
readProperties(path.str(), rootNode); readProperties(path, rootNode);
const_cast<FGAirport*>(this)->readThresholdData(rootNode); const_cast<FGAirport*>(this)->readThresholdData(rootNode);
} catch (sg_exception& e) { } catch (sg_exception& e) {
SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading threshold XML failed:" << e.getFormattedMessage()); SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading threshold XML failed:" << e.getFormattedMessage());
@ -691,7 +691,7 @@ void FGAirport::validateTowerData() const
try { try {
SGPropertyNode_ptr rootNode = new SGPropertyNode; SGPropertyNode_ptr rootNode = new SGPropertyNode;
readProperties(path.str(), rootNode); readProperties(path, rootNode);
const_cast<FGAirport*>(this)->readTowerData(rootNode); const_cast<FGAirport*>(this)->readTowerData(rootNode);
mHasTower = true; mHasTower = true;
} catch (sg_exception& e){ } catch (sg_exception& e){
@ -729,7 +729,7 @@ void FGAirport::validateILSData()
try { try {
SGPropertyNode_ptr rootNode = new SGPropertyNode; SGPropertyNode_ptr rootNode = new SGPropertyNode;
readProperties(path.str(), rootNode); readProperties(path, rootNode);
readILSData(rootNode); readILSData(rootNode);
} catch (sg_exception& e){ } catch (sg_exception& e){
SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading ils XML failed:" << e.getFormattedMessage()); SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading ils XML failed:" << e.getFormattedMessage());

View file

@ -89,12 +89,11 @@ public:
void parseAPT(const SGPath &aptdb_file) void parseAPT(const SGPath &aptdb_file)
{ {
std::string apt_dat = aptdb_file.str(); sg_gzifstream in(aptdb_file);
sg_gzifstream in(apt_dat);
if ( !in.is_open() ) { if ( !in.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << apt_dat ); SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << aptdb_file );
throw sg_io_exception("cannot open apt.dat file", apt_dat.c_str()); throw sg_io_exception("cannot open apt.dat file", aptdb_file);
} }
string line; string line;
@ -113,9 +112,8 @@ public:
// First line indicates IBM ("I") or Macintosh ("A") line endings. // First line indicates IBM ("I") or Macintosh ("A") line endings.
if ( stripped_line != "I" && stripped_line != "A" ) { if ( stripped_line != "I" && stripped_line != "A" ) {
std::string pb = "invalid first line (neither 'I' nor 'A')"; std::string pb = "invalid first line (neither 'I' nor 'A')";
SG_LOG( SG_GENERAL, SG_ALERT, apt_dat << ": " << pb); SG_LOG( SG_GENERAL, SG_ALERT, aptdb_file << ": " << pb);
throw sg_format_exception("cannot parse apt.dat file: " + pb, throw sg_format_exception("cannot parse apt.dat file: " + pb, aptdb_file.utf8Str());
apt_dat);
} }
} else { // second line of the file } else { // second line of the file
std::istringstream s(line); std::istringstream s(line);
@ -126,7 +124,7 @@ public:
} }
} // end of the apt.dat header } // end of the apt.dat header
throwExceptionIfStreamError(in, "apt.dat", apt_dat); throwExceptionIfStreamError(in, "apt.dat", aptdb_file.utf8Str());
while ( std::getline(in, line) ) { while ( std::getline(in, line) ) {
// 'line' may end with an \r character, see above // 'line' may end with an \r character, see above
@ -202,7 +200,7 @@ public:
} }
} }
throwExceptionIfStreamError(in, "apt.dat", apt_dat); throwExceptionIfStreamError(in, "apt.dat", aptdb_file.utf8Str());
finishAirport(); finishAirport();
} }
@ -569,7 +567,7 @@ bool airportDBLoad( const SGPath &aptdb_file )
bool metarDataLoad(const SGPath& metar_file) bool metarDataLoad(const SGPath& metar_file)
{ {
sg_gzifstream metar_in( metar_file.str() ); sg_gzifstream metar_in( metar_file );
if ( !metar_in.is_open() ) { if ( !metar_in.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << metar_file ); SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << metar_file );
return false; return false;

View file

@ -52,10 +52,10 @@ void FGSidStar::load(SGPath filename) {
string runway; string runway;
string name; string name;
try { try {
readProperties(filename.str(), &root); readProperties(filename, &root);
} catch (const sg_exception &) { } catch (const sg_exception &) {
SG_LOG(SG_GENERAL, SG_ALERT, SG_LOG(SG_GENERAL, SG_ALERT,
"Error reading AI flight plan: " << filename.str()); "Error reading AI flight plan: " << filename);
// cout << path.str() << endl; // cout << path.str() << endl;
return; return;
} }

View file

@ -54,7 +54,7 @@ void XMLLoader::load(FGGroundNetwork* net)
t.stamp(); t.stamp();
try { try {
FGGroundNetXMLLoader visitor(net); FGGroundNetXMLLoader visitor(net);
readXML(path.str(), visitor); readXML(path.local8BitStr(), visitor);
} catch (sg_exception& e) { } catch (sg_exception& e) {
SG_LOG(SG_NAVAID, SG_INFO, "parsing groundnet XML failed:" << e.getFormattedMessage()); SG_LOG(SG_NAVAID, SG_INFO, "parsing groundnet XML failed:" << e.getFormattedMessage());
} }
@ -105,8 +105,8 @@ bool XMLLoader::loadAirportXMLDataIntoVisitor(const string& aICAO,
return false; return false;
} }
SG_LOG(SG_GENERAL, SG_DEBUG, "loadAirportXMLDataIntoVisitor: loading from " << path.str()); SG_LOG(SG_GENERAL, SG_DEBUG, "loadAirportXMLDataIntoVisitor: loading from " << path);
readXML(path.str(), aVisitor); readXML(path.local8BitStr(), aVisitor);
return true; return true;
} }

View file

@ -197,13 +197,13 @@ void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string& name,
( (
SG_AUTOPILOT, SG_AUTOPILOT,
SG_INFO, SG_INFO,
"Reading property-rule configuration from " << config.str() "Reading property-rule configuration from " << config
); );
try try
{ {
SGPropertyNode_ptr configNode = new SGPropertyNode(); SGPropertyNode_ptr configNode = new SGPropertyNode();
readProperties( config.str(), configNode ); readProperties( config, configNode );
SG_LOG(SG_AUTOPILOT, SG_INFO, "adding property-rule subsystem " << name); SG_LOG(SG_AUTOPILOT, SG_INFO, "adding property-rule subsystem " << name);
addAutopilot(name, apNode, configNode); addAutopilot(name, apNode, configNode);
@ -214,7 +214,7 @@ void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string& name,
( (
SG_AUTOPILOT, SG_AUTOPILOT,
SG_ALERT, SG_ALERT,
"Failed to load property-rule configuration: " << config.str() "Failed to load property-rule configuration: " << config
<< ": " << e.getMessage() << ": " << e.getMessage()
); );
return; return;

View file

@ -359,7 +359,7 @@ void FGRouteMgr::postinit()
SGPath path(_pathNode->getStringValue()); SGPath path(_pathNode->getStringValue());
if (!path.isNull()) { if (!path.isNull()) {
SG_LOG(SG_AUTOPILOT, SG_INFO, "loading flight-plan from: " << path.str()); SG_LOG(SG_AUTOPILOT, SG_INFO, "loading flight-plan from: " << path);
loadRoute(path); loadRoute(path);
} }

View file

@ -48,16 +48,16 @@ namespace canvas
( (
SG_GL, SG_GL,
SG_INFO, SG_INFO,
"canvas::Text: using font file " << path.str() "canvas::Text: using font file " << path
); );
simgear::canvas::FontPtr font = osgText::readFontFile(path.c_str()); simgear::canvas::FontPtr font = osgText::readFontFile(path.local8BitStr());
if( !font ) if( !font )
SG_LOG SG_LOG
( (
SG_GL, SG_GL,
SG_ALERT, SG_ALERT,
"canvas::Text: Failed to open font file " << path.c_str() "canvas::Text: Failed to open font file " << path
); );
return font; return font;

View file

@ -65,10 +65,10 @@ void CockpitDisplayManager::init()
} }
SGPath config = globals->resolve_aircraft_path(path_n->getStringValue()); SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
SG_LOG( SG_COCKPIT, SG_INFO, "Reading cockpit displays from " << config.str() ); SG_LOG( SG_COCKPIT, SG_INFO, "Reading cockpit displays from " << config );
try { try {
readProperties( config.str(), config_props ); readProperties( config, config_props );
if (!build(config_props)) { if (!build(config_props)) {
throw sg_exception( throw sg_exception(
"Detected an internal inconsistency in the instrumentation\n" "Detected an internal inconsistency in the instrumentation\n"
@ -76,7 +76,7 @@ void CockpitDisplayManager::init()
} }
} catch (const sg_exception& e) { } catch (const sg_exception& e) {
SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: " SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: "
<< config.str() << ":" << e.getFormattedMessage() ); << config << ":" << e.getFormattedMessage() );
} }
// bind() created instruments before init. // bind() created instruments before init.

View file

@ -844,7 +844,7 @@ fgReadPanel (const string &relative_path)
SGPropertyNode root; SGPropertyNode root;
try { try {
readProperties(path.str(), &root); readProperties(path, &root);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {
guiErrorMessage("Error reading panel: ", e); guiErrorMessage("Error reading panel: ", e);
return 0; return 0;

View file

@ -233,9 +233,9 @@ FGJSBsim::FGJSBsim( double dt )
fdmex->Setdt( dt ); fdmex->Setdt( dt );
result = fdmex->LoadModel( aircraft_path.str(), result = fdmex->LoadModel( aircraft_path.local8BitStr(),
engine_path.str(), engine_path.local8BitStr(),
systems_path.str(), systems_path.local8BitStr(),
fgGetString("/sim/aero"), false ); fgGetString("/sim/aero"), false );
if (result) { if (result) {

View file

@ -321,9 +321,9 @@ void uiuc_init_aeromodel ()
// Called once from uiuc_init_2_wrapper // Called once from uiuc_init_2_wrapper
SGPath path(fgGetString("/sim/aircraft-dir")); SGPath path(fgGetString("/sim/aircraft-dir"));
path.append("aircraft.dat"); path.append("aircraft.dat");
std::cout << "We are using "<< path.str() << std::endl; std::cout << "We are using "<< path << std::endl;
uiuc_initializemaps(); // Initialize the <string,int> maps uiuc_initializemaps(); // Initialize the <string,int> maps
uiuc_menu(path.str()); // Read the specified aircraft file uiuc_menu(path.local8BitStr()); // Read the specified aircraft file
} }
void uiuc_force_moment(double dt) void uiuc_force_moment(double dt)

View file

@ -170,10 +170,10 @@ void YASim::init()
f.append(fgGetString("/sim/aero")); f.append(fgGetString("/sim/aero"));
f.concat(".xml"); f.concat(".xml");
try { try {
readXML(f.str(), *_fdm); readXML(f.local8BitStr(), *_fdm);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {
SG_LOG(SG_FLIGHT, SG_ALERT, SG_LOG(SG_FLIGHT, SG_ALERT,
"Error reading YASim FDM: '" << f.str() << "'" << std::endl "Error reading YASim FDM: '" << f << "'" << std::endl
<< e.getFormattedMessage()); << e.getFormattedMessage());
throw e; throw e;
} }

View file

@ -522,7 +522,7 @@ void AircraftItemModel::scanDirs()
SGPath rootAircraft(globals->get_fg_root()); SGPath rootAircraft(globals->get_fg_root());
rootAircraft.append("Aircraft"); rootAircraft.append("Aircraft");
dirs << QString::fromStdString(rootAircraft.str()); dirs << QString::fromStdString(rootAircraft.utf8Str());
m_scanThread = new AircraftScanThread(dirs); m_scanThread = new AircraftScanThread(dirs);
connect(m_scanThread, &AircraftScanThread::finished, this, connect(m_scanThread, &AircraftScanThread::finished, this,
@ -713,7 +713,7 @@ QVariant AircraftItemModel::dataFromPackage(const PackageRef& item, quint32 vari
} else if (role == AircraftPathRole) { } else if (role == AircraftPathRole) {
InstallRef i = item->existingInstall(); InstallRef i = item->existingInstall();
if (i.valid()) { if (i.valid()) {
return QString::fromStdString(i->primarySetPath().str()); return QString::fromStdString(i->primarySetPath().utf8Str());
} }
} else if (role == AircraftPackageIdRole) { } else if (role == AircraftPackageIdRole) {
return QString::fromStdString(item->variants()[variantIndex]); return QString::fromStdString(item->variants()[variantIndex]);
@ -794,7 +794,7 @@ QVariant AircraftItemModel::packageThumbnail(PackageRef p, int index, bool downl
path.append(p->thumbnails()[index]); path.append(p->thumbnails()[index]);
if (path.exists()) { if (path.exists()) {
QPixmap pix; QPixmap pix;
pix.load(QString::fromStdString(path.str())); pix.load(QString::fromStdString(path.utf8Str()));
// resize to the standard size // resize to the standard size
if (pix.height() > STANDARD_THUMBNAIL_HEIGHT) { if (pix.height() > STANDARD_THUMBNAIL_HEIGHT) {
pix = pix.scaledToHeight(STANDARD_THUMBNAIL_HEIGHT); pix = pix.scaledToHeight(STANDARD_THUMBNAIL_HEIGHT);

View file

@ -52,7 +52,7 @@ std::string stdStringFromCocoa(NSString* s)
NSURL* pathToNSURL(const SGPath& aPath) NSURL* pathToNSURL(const SGPath& aPath)
{ {
return [NSURL fileURLWithPath:stdStringToCocoa(aPath.str())]; return [NSURL fileURLWithPath:stdStringToCocoa(aPath.utf8Str())];
} }
SGPath URLToPath(NSURL* url) SGPath URLToPath(NSURL* url)

View file

@ -52,7 +52,7 @@ void QtFileDialog::exec()
} }
filter=filter+*it; filter=filter+*it;
} }
QFileDialog dlg(0,QString::fromStdString(_title),QString::fromStdString(_initialPath.str()),QString::fromStdString(filter)); QFileDialog dlg(0,QString::fromStdString(_title),QString::fromStdString(_initialPath.utf8Str()),QString::fromStdString(filter));
if (_usage==USE_SAVE_FILE) { if (_usage==USE_SAVE_FILE) {
dlg.setAcceptMode(QFileDialog::AcceptSave); dlg.setAcceptMode(QFileDialog::AcceptSave);
} }

View file

@ -655,7 +655,7 @@ void QtLauncher::setSceneryPaths()
SGPath terraSyncDir(downloadDir.toStdString()); SGPath terraSyncDir(downloadDir.toStdString());
terraSyncDir.append("TerraSync"); terraSyncDir.append("TerraSync");
if (terraSyncDir.exists()) { if (terraSyncDir.exists()) {
globals->append_fg_scenery(terraSyncDir.str()); globals->append_fg_scenery(terraSyncDir.utf8Str());
} }
} }

View file

@ -136,7 +136,7 @@ int main( int argc, char *argv[] ) {
SGPropertyNode *templatetree = new SGPropertyNode(); SGPropertyNode *templatetree = new SGPropertyNode();
try { try {
readProperties(templatefile.str().c_str(), templatetree); readProperties(templatefile, templatetree);
} catch (sg_io_exception & e) { } catch (sg_io_exception & e) {
cout << e.getFormattedMessage (); cout << e.getFormattedMessage ();
} }

View file

@ -1162,7 +1162,7 @@ do_load_xml_to_proptree(const SGPropertyNode * arg)
targetnode = const_cast<SGPropertyNode *>(arg)->getNode("data", true); targetnode = const_cast<SGPropertyNode *>(arg)->getNode("data", true);
try { try {
readProperties(validated_path.c_str(), targetnode, true); readProperties(validated_path, targetnode, true);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {
SG_LOG(SG_IO, SG_WARN, "loadxml: " << e.getFormattedMessage()); SG_LOG(SG_IO, SG_WARN, "loadxml: " << e.getFormattedMessage());
return false; return false;
@ -1247,7 +1247,7 @@ do_save_xml_from_proptree(const SGPropertyNode * arg)
return false; return false;
try { try {
writeProperties (validated_path.c_str(), sourcenode, true); writeProperties (validated_path, sourcenode, true);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {
SG_LOG(SG_IO, SG_WARN, "savexml: " << e.getFormattedMessage()); SG_LOG(SG_IO, SG_WARN, "savexml: " << e.getFormattedMessage());
return false; return false;

View file

@ -922,7 +922,7 @@ WayptRef FlightPlan::parseVersion1XMLWaypt(SGPropertyNode* aWP)
bool FlightPlan::loadPlainTextFormat(const SGPath& path) bool FlightPlan::loadPlainTextFormat(const SGPath& path)
{ {
try { try {
sg_gzifstream in(path.str().c_str()); sg_gzifstream in(path);
if (!in.is_open()) { if (!in.is_open()) {
throw sg_io_exception("Cannot open file for reading."); throw sg_io_exception("Cannot open file for reading.");
} }

View file

@ -263,7 +263,7 @@ public:
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
// see http://code.google.com/p/flightgear-bugs/issues/detail?id=1055 // see http://code.google.com/p/flightgear-bugs/issues/detail?id=1055
// for the UTF8 / path logic here // for the UTF8 / path logic here
std::string pathUtf8 = simgear::strutils::convertWindowsLocal8BitToUtf8(path.str()); std::string pathUtf8 = path.utf8Str();
sqlite3_open_v2(pathUtf8.c_str(), &db, openFlags, NULL); sqlite3_open_v2(pathUtf8.c_str(), &db, openFlags, NULL);
sqlite3_stmt_ptr checkTables = sqlite3_stmt_ptr checkTables =
@ -978,10 +978,10 @@ FGPositioned* NavDataCache::NavDataCachePrivate::loadById(sqlite3_int64 rowid,
bool NavDataCache::NavDataCachePrivate::isCachedFileModified(const SGPath& path, bool verbose) bool NavDataCache::NavDataCachePrivate::isCachedFileModified(const SGPath& path, bool verbose)
{ {
if (!path.exists()) { if (!path.exists()) {
throw sg_io_exception("isCachedFileModified: Missing file:" + path.str()); throw sg_io_exception("isCachedFileModified: Missing file:", path);
} }
sqlite_bind_temp_stdstring(statCacheCheck, 1, path.str()); sqlite_bind_temp_stdstring(statCacheCheck, 1, path.utf8Str());
bool isModified = true; bool isModified = true;
sgDebugPriority logLevel = verbose ? SG_WARN : SG_DEBUG; sgDebugPriority logLevel = verbose ? SG_WARN : SG_DEBUG;
if (execSelect(statCacheCheck)) { if (execSelect(statCacheCheck)) {
@ -1336,7 +1336,7 @@ bool NavDataCache::isCachedFileModified(const SGPath& path) const
void NavDataCache::stampCacheFile(const SGPath& path) void NavDataCache::stampCacheFile(const SGPath& path)
{ {
sqlite_bind_temp_stdstring(d->stampFileCache, 1, path.str()); sqlite_bind_temp_stdstring(d->stampFileCache, 1, path.utf8Str());
sqlite3_bind_int64(d->stampFileCache, 2, path.modTime()); sqlite3_bind_int64(d->stampFileCache, 2, path.modTime());
d->execInsert(d->stampFileCache); d->execInsert(d->stampFileCache);
} }
@ -2142,7 +2142,7 @@ NavDataCache::ThreadedGUISearch::ThreadedGUISearch(const std::string& term) :
{ {
SGPath p = NavDataCache::instance()->path(); SGPath p = NavDataCache::instance()->path();
int openFlags = SQLITE_OPEN_READONLY; int openFlags = SQLITE_OPEN_READONLY;
std::string pathUtf8 = simgear::strutils::convertWindowsLocal8BitToUtf8(p.str()); std::string pathUtf8 = p.utf8Str();
sqlite3_open_v2(pathUtf8.c_str(), &d->db, openFlags, NULL); sqlite3_open_v2(pathUtf8.c_str(), &d->db, openFlags, NULL);
std::string sql = "SELECT rowid FROM positioned WHERE name LIKE '%" + term std::string sql = "SELECT rowid FROM positioned WHERE name LIKE '%" + term

View file

@ -9,6 +9,7 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/misc/sgstream.hxx> #include <simgear/misc/sgstream.hxx>
#include <simgear/misc/strutils.hxx> #include <simgear/misc/strutils.hxx>
#include <simgear/misc/sg_path.hxx>
#include "GPSsmooth.hxx" #include "GPSsmooth.hxx"
@ -27,7 +28,7 @@ int GPSTrack::load( const string &file ) {
data.clear(); data.clear();
// openg the file // openg the file
sg_gzifstream in( file ); sg_gzifstream in( SGPath::fromLocal8Bit(file.c_str()) );
if ( !in.is_open() ) { if ( !in.is_open() ) {
cout << "Cannot open file: " << file << endl; cout << "Cannot open file: " << file << endl;
return 0; return 0;