}
void
-NewGUI::readDir (const char * path)
+NewGUI::readDir (const SGPath& path)
{
- ulDir * dir = ulOpenDir(path);
-
- 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")) {
- SGPropertyNode * props = new SGPropertyNode;
- try {
- readProperties(subpath, props);
- } catch (const sg_exception &) {
- SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog "
- << subpath);
- delete props;
- continue;
- }
- SGPropertyNode *nameprop = props->getNode("name");
- if (!nameprop) {
- SG_LOG(SG_INPUT, SG_WARN, "dialog " << subpath
- << " has no name; skipping.");
- delete props;
- continue;
- }
- string name = nameprop->getStringValue();
- _dialog_props[name] = props;
- }
+ simgear::Dir dir(path);
+ simgear::PathList xmls = dir.children(simgear::Dir::TYPE_FILE, ".xml");
+
+ for (unsigned int i=0; i<xmls.size(); ++i) {
+ SGPropertyNode * props = new SGPropertyNode;
+ try {
+ readProperties(xmls[i].str(), props);
+ } catch (const sg_exception &) {
+ SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog "
+ << xmls[i].str());
+ delete props;
+ continue;
+ }
+ SGPropertyNode *nameprop = props->getNode("name");
+ if (!nameprop) {
+ SG_LOG(SG_INPUT, SG_WARN, "dialog " << xmls[i].str()
+ << " has no name; skipping.");
+ delete props;
+ continue;
+ }
+ string name = nameprop->getStringValue();
- if (_dialog_props[name])
- delete (SGPropertyNode *)_dialog_props[name];
-
+ _dialog_props[name] = props;
}
- ulCloseDir(dir);
}