From 047c32c334ae7b2534959a9dac8cc31647d1d630 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 27 Aug 2002 03:03:37 +0000 Subject: Add constructors that accept the path to use (rather then SYSTEM or USER locations) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2607 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Preferences.cxx | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx index 12f7e4f45..0eb03d083 100644 --- a/src/Fl_Preferences.cxx +++ b/src/Fl_Preferences.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Preferences.cxx,v 1.1.2.18 2002/08/09 01:09:49 easysw Exp $" +// "$Id: Fl_Preferences.cxx,v 1.1.2.19 2002/08/27 03:03:37 easysw Exp $" // // Preferences methods for the Fast Light Tool Kit (FLTK). // @@ -65,6 +65,18 @@ Fl_Preferences::Fl_Preferences( Root root, const char *vendor, const char *appli } +/** + * create the initial preferences base + * - path: an application-supplied path + * example: Fl_Preferences base( "/usr/foo" ); + */ +Fl_Preferences::Fl_Preferences( const char *path, const char *vendor, const char *application ) +{ + node = new Node( "." ); + rootNode = new RootNode( this, path, vendor, application ); +} + + /** * create a Preferences node in relation to a parent node for reading and writing * - parent: base name for group @@ -669,6 +681,24 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char read(); } +// create the root node +// - construct the name of the file that will hold our preferences +Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, const char *path, const char *vendor, const char *application ) +{ + char filename[ FL_PATH_MAX ]; filename[0] = 0; + + snprintf(filename, sizeof(filename), "%s/%s.prefs", path, application); + + makePathForFile(filename); + + prefs_ = prefs; + filename_ = strdup(filename); + vendor_ = strdup(vendor); + application_ = strdup(application); + + read(); +} + // destroy the root node and all depending nodes Fl_Preferences::RootNode::~RootNode() { @@ -1054,5 +1084,5 @@ char Fl_Preferences::Node::remove() // -// End of "$Id: Fl_Preferences.cxx,v 1.1.2.18 2002/08/09 01:09:49 easysw Exp $". +// End of "$Id: Fl_Preferences.cxx,v 1.1.2.19 2002/08/27 03:03:37 easysw Exp $". // -- cgit v1.2.3