SGPropertyNode root;
try {
- readProperties(path.str(), &root);
+ readProperties(path, &root);
} 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());
return false;
}
path.append("AI/" + filename + ".xml");
try {
SGPropertyNode_ptr root = new SGPropertyNode;
- readProperties(path.str(), root);
+ readProperties(path, root);
return root;
} catch (const sg_exception &t) {
SG_LOG(SG_AI, SG_ALERT, "Failed to load scenario '"
- << path.str() << "': " << t.getFormattedMessage());
+ << path << "': " << t.getFormattedMessage());
}
return 0;
}
{
SGPropertyNode root;
try {
- readProperties(filename.str(), &root);
+ readProperties(filename, &root);
} catch (const sg_exception &) {
SG_LOG(SG_AI, SG_ALERT,
- "Error reading AI aircraft performance database: " << filename.str());
+ "Error reading AI aircraft performance database: " << filename);
return;
}
SGPath config = globals->resolve_aircraft_path(path);
try {
SG_LOG(SG_AI, SG_DEBUG,
- "Submodels: Trying to read AI submodels file: " << config.str());
- readProperties(config.str(), &root);
+ "Submodels: Trying to read AI submodels file: " << config);
+ readProperties(config, &root);
}
catch (const sg_exception &) {
SG_LOG(SG_AI, SG_ALERT,
- "Submodels: Unable to read AI submodels file: " << config.str());
+ "Submodels: Unable to read AI submodels file: " << config);
return;
}
try
{
SGPath path = globals->resolve_maybe_aircraft_path("ATC/atis.xml");
- readProperties( path.str(), atisSchemaNode );
+ readProperties( path, atisSchemaNode );
}
catch (const sg_exception& e)
{
{
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);
} catch (sg_io_exception &e)
{
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));
}
try {
SGPropertyNode_ptr rootNode = new SGPropertyNode;
- readProperties(path.str(), rootNode);
+ readProperties(path, rootNode);
const_cast<FGAirport*>(this)->readThresholdData(rootNode);
} catch (sg_exception& e) {
SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading threshold XML failed:" << e.getFormattedMessage());
try {
SGPropertyNode_ptr rootNode = new SGPropertyNode;
- readProperties(path.str(), rootNode);
+ readProperties(path, rootNode);
const_cast<FGAirport*>(this)->readTowerData(rootNode);
mHasTower = true;
} catch (sg_exception& e){
try {
SGPropertyNode_ptr rootNode = new SGPropertyNode;
- readProperties(path.str(), rootNode);
+ readProperties(path, rootNode);
readILSData(rootNode);
} catch (sg_exception& e){
SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading ils XML failed:" << e.getFormattedMessage());
void parseAPT(const SGPath &aptdb_file)
{
- std::string apt_dat = aptdb_file.str();
- sg_gzifstream in(apt_dat);
+ sg_gzifstream in(aptdb_file);
if ( !in.is_open() ) {
- SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << apt_dat );
- throw sg_io_exception("cannot open apt.dat file", apt_dat.c_str());
+ SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << aptdb_file );
+ throw sg_io_exception("cannot open apt.dat file", aptdb_file);
}
string line;
// First line indicates IBM ("I") or Macintosh ("A") line endings.
if ( stripped_line != "I" && stripped_line != "A" ) {
std::string pb = "invalid first line (neither 'I' nor 'A')";
- SG_LOG( SG_GENERAL, SG_ALERT, apt_dat << ": " << pb);
- throw sg_format_exception("cannot parse apt.dat file: " + pb,
- apt_dat);
+ SG_LOG( SG_GENERAL, SG_ALERT, aptdb_file << ": " << pb);
+ throw sg_format_exception("cannot parse apt.dat file: " + pb, aptdb_file.utf8Str());
}
} else { // second line of the file
std::istringstream s(line);
}
} // end of the apt.dat header
- throwExceptionIfStreamError(in, "apt.dat", apt_dat);
+ throwExceptionIfStreamError(in, "apt.dat", aptdb_file.utf8Str());
while ( std::getline(in, line) ) {
// 'line' may end with an \r character, see above
}
}
- throwExceptionIfStreamError(in, "apt.dat", apt_dat);
+ throwExceptionIfStreamError(in, "apt.dat", aptdb_file.utf8Str());
finishAirport();
}
bool metarDataLoad(const SGPath& metar_file)
{
- sg_gzifstream metar_in( metar_file.str() );
+ sg_gzifstream metar_in( metar_file );
if ( !metar_in.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << metar_file );
return false;
string runway;
string name;
try {
- readProperties(filename.str(), &root);
+ readProperties(filename, &root);
} catch (const sg_exception &) {
SG_LOG(SG_GENERAL, SG_ALERT,
- "Error reading AI flight plan: " << filename.str());
+ "Error reading AI flight plan: " << filename);
// cout << path.str() << endl;
return;
}
t.stamp();
try {
FGGroundNetXMLLoader visitor(net);
- readXML(path.str(), visitor);
+ readXML(path.local8BitStr(), visitor);
} catch (sg_exception& e) {
SG_LOG(SG_NAVAID, SG_INFO, "parsing groundnet XML failed:" << e.getFormattedMessage());
}
return false;
}
- SG_LOG(SG_GENERAL, SG_DEBUG, "loadAirportXMLDataIntoVisitor: loading from " << path.str());
- readXML(path.str(), aVisitor);
+ SG_LOG(SG_GENERAL, SG_DEBUG, "loadAirportXMLDataIntoVisitor: loading from " << path);
+ readXML(path.local8BitStr(), aVisitor);
return true;
}
(
SG_AUTOPILOT,
SG_INFO,
- "Reading property-rule configuration from " << config.str()
+ "Reading property-rule configuration from " << config
);
try
{
SGPropertyNode_ptr configNode = new SGPropertyNode();
- readProperties( config.str(), configNode );
+ readProperties( config, configNode );
SG_LOG(SG_AUTOPILOT, SG_INFO, "adding property-rule subsystem " << name);
addAutopilot(name, apNode, configNode);
(
SG_AUTOPILOT,
SG_ALERT,
- "Failed to load property-rule configuration: " << config.str()
+ "Failed to load property-rule configuration: " << config
<< ": " << e.getMessage()
);
return;
SGPath path(_pathNode->getStringValue());
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);
}
(
SG_GL,
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 )
SG_LOG
(
SG_GL,
SG_ALERT,
- "canvas::Text: Failed to open font file " << path.c_str()
+ "canvas::Text: Failed to open font file " << path
);
return font;
}
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 {
- readProperties( config.str(), config_props );
+ readProperties( config, config_props );
if (!build(config_props)) {
throw sg_exception(
"Detected an internal inconsistency in the instrumentation\n"
}
} catch (const sg_exception& e) {
SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: "
- << config.str() << ":" << e.getFormattedMessage() );
+ << config << ":" << e.getFormattedMessage() );
}
// bind() created instruments before init.
SGPropertyNode root;
try {
- readProperties(path.str(), &root);
+ readProperties(path, &root);
} catch (const sg_exception &e) {
guiErrorMessage("Error reading panel: ", e);
return 0;
fdmex->Setdt( dt );
- result = fdmex->LoadModel( aircraft_path.str(),
- engine_path.str(),
- systems_path.str(),
+ result = fdmex->LoadModel( aircraft_path.local8BitStr(),
+ engine_path.local8BitStr(),
+ systems_path.local8BitStr(),
fgGetString("/sim/aero"), false );
if (result) {
// Called once from uiuc_init_2_wrapper
SGPath path(fgGetString("/sim/aircraft-dir"));
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_menu(path.str()); // Read the specified aircraft file
+ uiuc_menu(path.local8BitStr()); // Read the specified aircraft file
}
void uiuc_force_moment(double dt)
f.append(fgGetString("/sim/aero"));
f.concat(".xml");
try {
- readXML(f.str(), *_fdm);
+ readXML(f.local8BitStr(), *_fdm);
} catch (const sg_exception &e) {
SG_LOG(SG_FLIGHT, SG_ALERT,
- "Error reading YASim FDM: '" << f.str() << "'" << std::endl
+ "Error reading YASim FDM: '" << f << "'" << std::endl
<< e.getFormattedMessage());
throw e;
}
SGPath rootAircraft(globals->get_fg_root());
rootAircraft.append("Aircraft");
- dirs << QString::fromStdString(rootAircraft.str());
+ dirs << QString::fromStdString(rootAircraft.utf8Str());
m_scanThread = new AircraftScanThread(dirs);
connect(m_scanThread, &AircraftScanThread::finished, this,
} else if (role == AircraftPathRole) {
InstallRef i = item->existingInstall();
if (i.valid()) {
- return QString::fromStdString(i->primarySetPath().str());
+ return QString::fromStdString(i->primarySetPath().utf8Str());
}
} else if (role == AircraftPackageIdRole) {
return QString::fromStdString(item->variants()[variantIndex]);
path.append(p->thumbnails()[index]);
if (path.exists()) {
QPixmap pix;
- pix.load(QString::fromStdString(path.str()));
+ pix.load(QString::fromStdString(path.utf8Str()));
// resize to the standard size
if (pix.height() > STANDARD_THUMBNAIL_HEIGHT) {
pix = pix.scaledToHeight(STANDARD_THUMBNAIL_HEIGHT);
NSURL* pathToNSURL(const SGPath& aPath)
{
- return [NSURL fileURLWithPath:stdStringToCocoa(aPath.str())];
+ return [NSURL fileURLWithPath:stdStringToCocoa(aPath.utf8Str())];
}
SGPath URLToPath(NSURL* url)
}
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) {
dlg.setAcceptMode(QFileDialog::AcceptSave);
}
SGPath terraSyncDir(downloadDir.toStdString());
terraSyncDir.append("TerraSync");
if (terraSyncDir.exists()) {
- globals->append_fg_scenery(terraSyncDir.str());
+ globals->append_fg_scenery(terraSyncDir.utf8Str());
}
}
SGPropertyNode *templatetree = new SGPropertyNode();
try {
- readProperties(templatefile.str().c_str(), templatetree);
+ readProperties(templatefile, templatetree);
} catch (sg_io_exception & e) {
cout << e.getFormattedMessage ();
}
targetnode = const_cast<SGPropertyNode *>(arg)->getNode("data", true);
try {
- readProperties(validated_path.c_str(), targetnode, true);
+ readProperties(validated_path, targetnode, true);
} catch (const sg_exception &e) {
SG_LOG(SG_IO, SG_WARN, "loadxml: " << e.getFormattedMessage());
return false;
return false;
try {
- writeProperties (validated_path.c_str(), sourcenode, true);
+ writeProperties (validated_path, sourcenode, true);
} catch (const sg_exception &e) {
SG_LOG(SG_IO, SG_WARN, "savexml: " << e.getFormattedMessage());
return false;
bool FlightPlan::loadPlainTextFormat(const SGPath& path)
{
try {
- sg_gzifstream in(path.str().c_str());
+ sg_gzifstream in(path);
if (!in.is_open()) {
throw sg_io_exception("Cannot open file for reading.");
}
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
// see http://code.google.com/p/flightgear-bugs/issues/detail?id=1055
// 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_stmt_ptr checkTables =
bool NavDataCache::NavDataCachePrivate::isCachedFileModified(const SGPath& path, bool verbose)
{
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;
sgDebugPriority logLevel = verbose ? SG_WARN : SG_DEBUG;
if (execSelect(statCacheCheck)) {
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());
d->execInsert(d->stampFileCache);
}
{
SGPath p = NavDataCache::instance()->path();
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);
std::string sql = "SELECT rowid FROM positioned WHERE name LIKE '%" + term
#include <simgear/constants.h>
#include <simgear/misc/sgstream.hxx>
#include <simgear/misc/strutils.hxx>
+#include <simgear/misc/sg_path.hxx>
#include "GPSsmooth.hxx"
data.clear();
// openg the file
- sg_gzifstream in( file );
+ sg_gzifstream in( SGPath::fromLocal8Bit(file.c_str()) );
if ( !in.is_open() ) {
cout << "Cannot open file: " << file << endl;
return 0;