X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInput%2FFGDeviceConfigurationMap.cxx;h=b8ce13505f83d35c817ff13c73d2dc19ac887175;hb=088b3bc79134c01bfaf5e219f707eadaf8a889b6;hp=1cd4f1c4d3e07f029422aa9cd709c1494a853cc8;hpb=71d7f043a8aaed896b5a3ed6c839cf5457871d4b;p=flightgear.git diff --git a/src/Input/FGDeviceConfigurationMap.cxx b/src/Input/FGDeviceConfigurationMap.cxx index 1cd4f1c4d..b8ce13505 100644 --- a/src/Input/FGDeviceConfigurationMap.cxx +++ b/src/Input/FGDeviceConfigurationMap.cxx @@ -26,24 +26,27 @@ # include #endif +#include + #include "FGDeviceConfigurationMap.hxx" + +#include #include #include
+using simgear::PropertyList; + FGDeviceConfigurationMap::FGDeviceConfigurationMap( const char * relative_path, SGPropertyNode_ptr aBase, const char * aChildname ) : 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); - vector childNodes = base->getChildren(childname); + PropertyList childNodes = base->getChildren(childname); for (int k = (int)childNodes.size() - 1; k >= 0; k--) { SGPropertyNode *n = childNodes[k]; - vector names = n->getChildren("name"); + PropertyList names = n->getChildren("name"); if (names.size() ) // && (n->getChildren("axis").size() || n->getChildren("button").size())) for (unsigned int j = 0; j < names.size(); j++) (*this)[names[j]->getStringValue()] = n; @@ -55,26 +58,22 @@ 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; + simgear::Dir dir(path); + simgear::PathList children = dir.children(simgear::Dir::TYPE_FILE | + simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT); - SGPath p(path.str()); - p.append(dent->d_name); - scan_dir(p, index); + for (unsigned int c=0; cgetChild(childname, (*index)++, true); + readProperties(path.str(), n); + n->setStringValue("source", path.c_str()); } - ulCloseDir(dir); - - } 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()); } }