Remove direct uses of PLIB ulXXX functions
This commit is contained in:
parent
0e53e2cbb1
commit
7ccba95b9c
8 changed files with 62 additions and 124 deletions
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <plib/ul.h>
|
||||
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
#include <Environment/environment.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
|
|
@ -10,14 +10,13 @@
|
|||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <sys/types.h>
|
||||
#include <plib/ul.h>
|
||||
|
||||
#include <plib/pu.h>
|
||||
#include <plib/ul.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
|
||||
|
@ -56,11 +55,8 @@ void
|
|||
NewGUI::init ()
|
||||
{
|
||||
setStyle();
|
||||
char path1[1024];
|
||||
char path2[1024];
|
||||
ulMakePath(path1, globals->get_fg_root().c_str(), "gui");
|
||||
ulMakePath(path2, path1, "dialogs");
|
||||
readDir(path2);
|
||||
SGPath p(globals->get_fg_root(), "gui/dialogs");
|
||||
readDir(p);
|
||||
_menubar->init();
|
||||
}
|
||||
|
||||
|
@ -233,19 +229,6 @@ NewGUI::setMenuBarVisible (bool visible)
|
|||
_menubar->hide();
|
||||
}
|
||||
|
||||
static bool
|
||||
test_extension (const char * path, const char * ext)
|
||||
{
|
||||
int pathlen = strlen(path);
|
||||
int extlen = strlen(ext);
|
||||
|
||||
for (int i = 1; i <= pathlen && i <= extlen; i++) {
|
||||
if (path[pathlen-i] != ext[extlen-i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
NewGUI::newDialog (SGPropertyNode* props)
|
||||
{
|
||||
|
@ -260,37 +243,24 @@ NewGUI::newDialog (SGPropertyNode* props)
|
|||
}
|
||||
|
||||
void
|
||||
NewGUI::readDir (const char * path)
|
||||
NewGUI::readDir (const SGPath& path)
|
||||
{
|
||||
ulDir * dir = ulOpenDir(path);
|
||||
simgear::Dir dir(path);
|
||||
simgear::PathList xmls = dir.children(simgear::Dir::TYPE_FILE, ".xml");
|
||||
|
||||
if (dir == 0) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Failed to read GUI files from "
|
||||
<< path);
|
||||
return;
|
||||
}
|
||||
|
||||
for (ulDirEnt * dirEnt = ulReadDir(dir);
|
||||
dirEnt != 0;
|
||||
dirEnt = ulReadDir(dir)) {
|
||||
|
||||
char subpath[1024];
|
||||
|
||||
ulMakePath(subpath, path, dirEnt->d_name);
|
||||
|
||||
if (!dirEnt->d_isdir && test_extension(subpath, ".xml")) {
|
||||
for (unsigned int i=0; i<xmls.size(); ++i) {
|
||||
SGPropertyNode * props = new SGPropertyNode;
|
||||
try {
|
||||
readProperties(subpath, props);
|
||||
readProperties(xmls[i].str(), props);
|
||||
} catch (const sg_exception &) {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog "
|
||||
<< subpath);
|
||||
<< xmls[i].str());
|
||||
delete props;
|
||||
continue;
|
||||
}
|
||||
SGPropertyNode *nameprop = props->getNode("name");
|
||||
if (!nameprop) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "dialog " << subpath
|
||||
SG_LOG(SG_INPUT, SG_WARN, "dialog " << xmls[i].str()
|
||||
<< " has no name; skipping.");
|
||||
delete props;
|
||||
continue;
|
||||
|
@ -301,8 +271,6 @@ NewGUI::readDir (const char * path)
|
|||
|
||||
_dialog_props[name] = props;
|
||||
}
|
||||
}
|
||||
ulCloseDir(dir);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ private:
|
|||
void clear_colors();
|
||||
|
||||
// Read all the configuration files in a directory.
|
||||
void readDir (const char * path);
|
||||
void readDir (const SGPath& path);
|
||||
|
||||
FGMenuBar * _menubar;
|
||||
FGDialog * _active_dialog;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include <vector>
|
||||
#include <simgear/structure/SGBinding.hxx>
|
||||
#include <plib/ul.h>
|
||||
|
||||
#if defined( UL_WIN32 )
|
||||
#define TGT_PLATFORM "windows"
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
|
||||
#include "FGDeviceConfigurationMap.hxx"
|
||||
|
||||
#include <plib/ul.h>
|
||||
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
||||
|
@ -41,11 +40,8 @@ FGDeviceConfigurationMap::FGDeviceConfigurationMap( const char * relative_path,
|
|||
base(aBase),
|
||||
childname(aChildname)
|
||||
{
|
||||
SGPath path(globals->get_fg_root());
|
||||
path.append( relative_path );
|
||||
|
||||
int index = 1000;
|
||||
scan_dir( path, &index);
|
||||
scan_dir( SGPath(globals->get_fg_root(), relative_path), &index);
|
||||
|
||||
PropertyList childNodes = base->getChildren(childname);
|
||||
for (int k = (int)childNodes.size() - 1; k >= 0; k--) {
|
||||
|
@ -62,27 +58,23 @@ FGDeviceConfigurationMap::~FGDeviceConfigurationMap()
|
|||
base->removeChildren( childname );
|
||||
}
|
||||
|
||||
void FGDeviceConfigurationMap::scan_dir( SGPath & path, int *index)
|
||||
void FGDeviceConfigurationMap::scan_dir(const SGPath & path, int *index)
|
||||
{
|
||||
ulDir *dir = ulOpenDir(path.c_str());
|
||||
if (dir) {
|
||||
ulDirEnt* dent;
|
||||
while ((dent = ulReadDir(dir)) != 0) {
|
||||
if (dent->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
SGPath p(path.str());
|
||||
p.append(dent->d_name);
|
||||
scan_dir(p, index);
|
||||
}
|
||||
ulCloseDir(dir);
|
||||
simgear::Dir dir(path);
|
||||
simgear::PathList children = dir.children(simgear::Dir::TYPE_FILE |
|
||||
simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||
|
||||
for (unsigned int c=0; c<children.size(); ++c) {
|
||||
SGPath path(children[c]);
|
||||
if (path.isDir()) {
|
||||
scan_dir(path, index);
|
||||
} else if (path.extension() == "xml") {
|
||||
SG_LOG(SG_INPUT, SG_DEBUG, "Reading joystick file " << path.str());
|
||||
SGPropertyNode_ptr n = base->getChild(childname, (*index)++, true);
|
||||
readProperties(path.str(), n);
|
||||
n->setStringValue("source", path.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,16 +30,17 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#include <map>
|
||||
|
||||
class SGPath;
|
||||
|
||||
class FGDeviceConfigurationMap : public std::map<std::string,SGPropertyNode_ptr> {
|
||||
public:
|
||||
FGDeviceConfigurationMap ( const char * relative_path, SGPropertyNode_ptr base, const char * childname );
|
||||
virtual ~FGDeviceConfigurationMap();
|
||||
private:
|
||||
void scan_dir( SGPath & path, int *index);
|
||||
void scan_dir(const SGPath & path, int *index);
|
||||
SGPropertyNode_ptr base;
|
||||
const char * childname;
|
||||
};
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <stdio.h> //snprintf
|
||||
#ifdef _WIN32
|
||||
# include <io.h> //lseek, read, write
|
||||
|
@ -38,8 +40,6 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <plib/ul.h>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/io/iochannel.hxx>
|
||||
|
|
|
@ -51,10 +51,9 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <plib/ul.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/route/waypoint.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
@ -126,42 +125,23 @@ FGTrafficManager::~FGTrafficManager()
|
|||
|
||||
void FGTrafficManager::init()
|
||||
{
|
||||
ulDir *d, *d2;
|
||||
ulDirEnt *dent, *dent2;
|
||||
|
||||
heuristicsVector heuristics;
|
||||
HeuristicMap heurMap;
|
||||
|
||||
if (string(fgGetString("/sim/traffic-manager/datafile")) == string("")) {
|
||||
SGPath aircraftDir = globals->get_fg_root();
|
||||
SGPath path = aircraftDir;
|
||||
simgear::Dir trafficDir(SGPath(globals->get_fg_root(), "AI/Traffic"));
|
||||
simgear::PathList d = trafficDir.children(simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||
|
||||
aircraftDir.append("AI/Traffic");
|
||||
if ((d = ulOpenDir(aircraftDir.c_str())) != NULL) {
|
||||
while ((dent = ulReadDir(d)) != NULL) {
|
||||
if (string(dent->d_name) != string(".") &&
|
||||
string(dent->d_name) != string("..") && dent->d_isdir) {
|
||||
SGPath currACDir = aircraftDir;
|
||||
currACDir.append(dent->d_name);
|
||||
if ((d2 = ulOpenDir(currACDir.c_str())) == NULL)
|
||||
return;
|
||||
while ((dent2 = ulReadDir(d2)) != NULL) {
|
||||
SGPath currFile = currACDir;
|
||||
currFile.append(dent2->d_name);
|
||||
if (currFile.extension() == string("xml")) {
|
||||
SGPath currFile = currACDir;
|
||||
currFile.append(dent2->d_name);
|
||||
for (unsigned int i=0; i<d.size(); ++i) {
|
||||
simgear::Dir d2(d[i]);
|
||||
simgear::PathList trafficFiles = d2.children(simgear::Dir::TYPE_FILE, ".xml");
|
||||
for (unsigned int j=0; j<trafficFiles.size(); ++j) {
|
||||
SGPath curFile = trafficFiles[j];
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG,
|
||||
"Scanning " << currFile.
|
||||
str() << " for traffic");
|
||||
readXML(currFile.str(), *this);
|
||||
"Scanning " << curFile.str() << " for traffic");
|
||||
readXML(curFile.str(), *this);
|
||||
}
|
||||
}
|
||||
ulCloseDir(d2);
|
||||
}
|
||||
}
|
||||
ulCloseDir(d);
|
||||
}
|
||||
} else {
|
||||
fgSetBool("/sim/traffic-manager/heuristics", false);
|
||||
SGPath path = string(fgGetString("/sim/traffic-manager/datafile"));
|
||||
|
|
Loading…
Reference in a new issue