From f61d73e5465a771a63772f119e48ba1cac8e9ad4 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 21 Jan 2003 02:08:00 +0000 Subject: [PATCH] Make fgLoadProps more flexible, to read from $FG_ROOT or the current directory. --- src/Main/fg_props.cxx | 23 ++++++++++++++++++----- src/Main/fg_props.hxx | 13 ++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 5a2460c3b..23c51dd3c 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -683,12 +683,25 @@ fgLoadFlight (istream &input) } -void -fgLoadProps (const char * path, SGPropertyNode * props) +bool +fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root) { - SGPath loadpath(globals->get_fg_root()); - loadpath.append(path); - readProperties(loadpath.c_str(), props); + string fullpath; + if (in_fg_root) { + SGPath loadpath(globals->get_fg_root()); + loadpath.append(path); + fullpath = loadpath.str(); + } else { + fullpath = path; + } + + try { + readProperties(fullpath, props); + } catch (const sg_exception &e) { + guiErrorMessage("Error reading properties: ", e); + return false; + } + return true; } diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 0e5f311ac..4a5822997 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -65,11 +65,18 @@ extern bool fgLoadFlight (istream &input); /** - * Load properties from a file relative to $FG_ROOT. + * Load properties from a file. * - * @param file The file name relative to $FG_ROOT. + * @param file The relative or absolute filename. + * @param props The property node to load the properties into. + * @param in_fg_root If true, look for the file relative to + * $FG_ROOT; otherwise, look for the file relative to the + * current working directory. + * @return true if the properties loaded successfully, false + * otherwise. */ -extern void fgLoadProps (const char * path, SGPropertyNode * props); +extern bool fgLoadProps (const char * path, SGPropertyNode * props, + bool in_fg_root = true);