preferences question

48 views
Skip to first unread message

david allen

unread,
Sep 19, 2017, 12:27:02 PM9/19/17
to fltk.general
I was playing with preferences.cxx in the test folder. The data file seems to be subsidiary to a folder .fltk. Is there a way to change that?

Ian MacArthur

unread,
Sep 19, 2017, 5:05:49 PM9/19/17
to fltkg...@googlegroups.com
On Tue Sep 19 2017 17:27:02, david allen wrote:
> I was playing with preferences.cxx in the test folder. The data file seems to be subsidiary to a folder .fltk. Is there a way to change that?


It’s done based on the 3 text strings you pass to the constructor of the Fl_Preferences object, for path, vendor and application name.


Greg Ercolano

unread,
Sep 19, 2017, 5:30:37 PM9/19/17
to fltkg...@googlegroups.com
Right, so instead of:

Fl_Preferences app(Fl_Preferences::USER, "project", "application");

..which might end up creating this path on unix systems:

/usr/you/.fltk/fltk.org/project/application/

You could use instead:

Fl_Preferences app("/var/tmp/preferences", "project", "application");

..which would result in:

/var/tmp/preferences/project/application/

Beware of platform specific pathnames when building apps intended
to work across platforms.

Jean-Yves Garneau

unread,
Sep 22, 2017, 11:00:16 AM9/22/17
to fltk.general
You can also create preferences file in the same folder as application with Fl_Preferences(".", "VendorName", "AppName").

Ian MacArthur

unread,
Sep 22, 2017, 6:32:04 PM9/22/17
to fltkg...@googlegroups.com
On Fri Sep 22 2017 16:00:16, Jean-Yves Garneau wrote:
> You can also create preferences file in the same folder as application with Fl_Preferences(".", "VendorName", "AppName").
>


Though be cautious with this, since it uses a relative path “.” rather than a full path, so may depend on the CWD your application gets (at startup or whenever you instantiate the preferences object.)

Now, under Win32, the CWD at startup is generally the same folder the exe resides in, but other WM, and particularly X11 WM’s, may set the CWD differently for various reasons (often security based), so it is not always safe to assume that the CWD is the exe directory...

If I want to do that, I usually use code to ascertain the *actual* home directory for the app and make sure the CWD is set accordingly.



david allen

unread,
Oct 1, 2017, 4:37:46 PM10/1/17
to fltk.general
Thanks for the responses. I am now able to do what I wanted.


On Tuesday, September 19, 2017 at 12:27:02 PM UTC-4, david allen wrote:
Reply all
Reply to author
Forward
0 new messages