mirror of
https://github.com/fltk/fltk.git
synced 2026-06-06 00:22:42 +08:00
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
This commit is contained in:
+4
-2
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Preferences.H,v 1.1.2.9 2002/08/14 16:19:48 easysw Exp $"
|
||||
// "$Id: Fl_Preferences.H,v 1.1.2.10 2002/08/27 03:03:34 easysw Exp $"
|
||||
//
|
||||
// Preferences definitions for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
// enum Type { win32, macos, fltk };
|
||||
|
||||
Fl_Preferences( Root root, const char *vendor, const char *application );
|
||||
Fl_Preferences( const char *path, const char *vendor, const char *application );
|
||||
Fl_Preferences( Fl_Preferences&, const char *group );
|
||||
Fl_Preferences( Fl_Preferences*, const char *group );
|
||||
~Fl_Preferences();
|
||||
@@ -139,6 +140,7 @@ private:
|
||||
char *vendor_, *application_;
|
||||
public:
|
||||
RootNode( Fl_Preferences *, Root root, const char *vendor, const char *application );
|
||||
RootNode( Fl_Preferences *, const char *path, const char *vendor, const char *application );
|
||||
~RootNode();
|
||||
int read();
|
||||
int write();
|
||||
@@ -155,5 +157,5 @@ private:
|
||||
#endif // !Fl_Preferences_H
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Preferences.H,v 1.1.2.9 2002/08/14 16:19:48 easysw Exp $".
|
||||
// End of "$Id: Fl_Preferences.H,v 1.1.2.10 2002/08/27 03:03:34 easysw Exp $".
|
||||
//
|
||||
|
||||
+32
-2
@@ -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 $".
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user