[haiku-development] [problem] Strange behavior of find_directory(B_USER_SETTINGS_DIRECTORY)

  • From: Alex Hitech <ahitech@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 23 Jul 2009 11:58:24 +0300

Hello,

I have a problem in development of an application under Haiku.

I'm developing a program under Haiku 31545 gcc2.95, using BeIDE with
DontWorry plugin. At one point I need to read and parse Tracker's settings
file, located at /boot/home/config/settings/Tracker/TrackerSettings. In
order to accomplish this, I've created the following construction:

BPath* pathToSettings = NULL;
FILE* settingsFile;
........
if ( (find_directory (B_USER_SETTINGS_DIRECTORY,
pathToSettings,
false, NULL) != B_OK ) ||
( pathToSettings == NULL ) )
{
ErrorAlert* error = new ErrorAlert («Can't find the user settings
directory!», true);
return (NULL);
}
pathToSettings–>Append(«Tracker/TrackerSettings», true);

/* Now the varible pathToSettings is set to Tracker Settings file. */

settingsFile = fopen (pathToSettings–>Path(), “r”);

(ErrorAlert is a derived class of Alert, its object is a self-showing alert
box. It's something I use for debugging).

When I run this code, I'm always arriving to «Can't find the user settings
directory!» message. It happens also when I remove the check for
"pathToSettings == NULL" from the "if" condition - in my opition, it means
that find_directory fails. Therefore I use a more archaic and less stable
workaround:

settingsFile = fopen («/boot/home/config/settings/Tracker/TrackerSettings»,
“r”);

- but I would like to use "find_directory", of course. What is wrong with
that construction? I presume, it's something very minor, since the same
construction with B_COMMON_SETTINGS_DIRECTORY works perfectly, (but it is
not what I want, since the common settings directory doesn't have the user's
TrackerSettings file).

Isn't it better just to stop thinking about this code, since everything I
need from TrackerSettings file - date separator, first day of week and MM,
DD and YYYY order in the date - will be available from the Locale Kit as
soon as it enters the code?

Other related posts: